-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dart): setSettingsThenSaveObjects (+ local vars)
- Loading branch information
Showing
4 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
templates/dart/guides/search/setSettingsThenSaveObjects.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{> snippets/import}} | ||
|
||
final playlists = []; // Your records | ||
|
||
String getAppIDFor(String _) { | ||
return ""; // Implement your own logic here | ||
} | ||
|
||
String getIndexingApiKeyFor(String _) { | ||
return ""; // Implement your own logic here | ||
} | ||
|
||
void setSettingsThenSaveObjects() async { | ||
for (final playlist in playlists) { | ||
// Fetch from your own data storage and with your own code | ||
// the associated application ID and API key for this user | ||
final appId = getAppIDFor(playlist["user"]); | ||
final apiKey = getIndexingApiKeyFor(playlist["user"]); | ||
final client = SearchClient(appId: appId, apiKey: apiKey); | ||
final settings = IndexSettings( | ||
attributesForFaceting: ['filterOnly(userID)'], | ||
); | ||
await {{#dynamicSnippet}}setSettings{{/dynamicSnippet}}; | ||
|
||
final batchParams = BatchWriteParams( | ||
requests: playlists | ||
.map((record) => BatchRequest( | ||
action: Action.addObject, | ||
body: record, | ||
)) | ||
.toList()); | ||
await {{#dynamicSnippet}}batchChunks{{/dynamicSnippet}}; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
templates/kotlin/guides/search/setSettingsThenSaveObjects.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters