File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ { {> snippets/import} }
2+
3+ List<Map <String, String >> getAllAppIDConfigurations() {
4+ return [/* A list of your MCM AppID/ApiKey pairs */];
5+ }
6+
7+ List<Map > playlists = [/* Your records */];
8+
9+ void saveObjectsMCM() async {
10+ var configurations = getAllAppIDConfigurations();
11+
12+ for (var configuration in configurations) {
13+ var appId = configuration[' appID' ] ?? " " ;
14+ var apiKey = configuration[' apiKey' ] ?? " " ;
15+ var client = SearchClient(appId: appId, apiKey: apiKey);
16+
17+ try {
18+ var batchParams = BatchWriteParams(
19+ requests: playlists
20+ .map((record) => BatchRequest(
21+ action: Action.addObject,
22+ body: record,
23+ )).toList()
24+ );
25+ await {{#dynamicSnippet} }batchChunks{ {/dynamicSnippet} };
26+ } catch (e) {
27+ throw Exception(' Error for appID $appId: $e' );
28+ }
29+ }
30+ }
Original file line number Diff line number Diff line change 11{ {> snippets/import} }
22import com.algolia.client.model.search.*
33
4+ val getAllAppIDConfigurations: () -> Map<String , String > = {
5+ mapOf() // A map of your MCM AppID/ApiKey pairs
6+ }
7+
8+ val playlists: List<JsonObject > = listOf() // Your records
9+
410suspend fun saveObjectsMCM() {
511 val configurations = getAllAppIDConfigurations()
612
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ import scala.concurrent.ExecutionContext.Implicits.global
44{ {> snippets/import} }
55import algoliasearch.config.RequestOptions
66
7+ val getAllAppIDConfigurations: () => Map[String, String] = () => {
8+ Map(/* A map of your MCM AppID/ApiKey pairs */)
9+ }
10+
11+ val playlists: List[Any] = List(/* Your records */)
12+
713def saveObjectsMCM(): Future[Unit] = {
814 val configurations = getAllAppIDConfigurations()
915
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ import Foundation
66import Core
77{ {> snippets/import} }
88
9+ let getAllAppIDConfigurations: () -> [(String, String)] = {
10+ return [/* A list of your MCM AppID/ApiKey pairs */]
11+ }
12+
13+ let playlists: [[String: AnyCodable]] = [/* Your records */]
14+
915func saveObjectsMCM() async throws {
1016 // Fetch from your own data storage and with your own code
1117 // the list of application IDs and API keys to target each cluster
You can’t perform that action at this time.
0 commit comments