Skip to content

Commit

Permalink
[AUTO]Updating snippets (#535)
Browse files Browse the repository at this point in the history
Files changed:
M	snippets.json

Co-authored-by: danielhenrymantilla <[email protected]>
  • Loading branch information
dittotester and danielhenrymantilla authored Apr 19, 2023
1 parent b39634d commit 4240bbc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@
"sync-basic": "try {\n ditto.start_sync();\n} catch (const DittoError &err) {\n std::cerr << err.what();\n}\n\n",
"subscribe": "std::shared_ptr<ditto::Subscription> subscription =\n collection.find(\"color == 'red'\").subscribe();\n\n",
"sync-observe": "std::shared_ptr<LiveQuery> liveQuery =\n collection.find(\"color == 'red'\")\n .observe_local([&](std::vector<Document> docs, LiveQueryEvent event) {\n // do something\n });\n\n",
"online-playground": "Ditto ditto;\nauto identity =\n Identity::OnlinePlayground(\"00000000-0000-4000-0000-000000000000\",\n \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\", true);\ntry {\n ditto = Ditto(identity, dir);\n ditto.set_minimum_log_level(LogLevel::debug);\n ditto.start_sync();\n} catch (const DittoError &err) {\n}\n\n",
"offline-playground": "Ditto ditto;\nauto identity =\n Identity::OfflinePlayground(\"00000000-0000-4000-0000-000000000000\", 1234);\ntry {\n ditto = Ditto(identity, dir);\n\n ditto.set_offline_only_license_token(valid_license);\n ditto.start_sync();\n} catch (const DittoError &err) {\n}\n\n",
"online-playground": "auto identity =\n Identity::OnlinePlayground(\"00000000-0000-4000-0000-000000000000\",\n \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\", true);\ntry {\n Ditto ditto = Ditto(identity, dir);\n ditto.set_minimum_log_level(LogLevel::debug);\n ditto.start_sync();\n} catch (const DittoError &err) {\n}\n\n",
"offline-playground": "auto identity =\n Identity::OfflinePlayground(\"00000000-0000-4000-0000-000000000000\", 1234);\ntry {\n Ditto ditto = Ditto(identity, dir);\n\n ditto.set_offline_only_license_token(valid_license);\n ditto.start_sync();\n} catch (const DittoError &err) {\n}\n\n",
"network-remote-ditto": "auto config = ditto::TransportConfig();\n// Connect explicitly to remote devices\nconfig.connect.tcp_servers.insert(\"135.1.5.5:12345\");\nconfig.connect.tcp_servers.insert(\"185.1.5.5:12345\");\n\n// set the transport config\nditto.set_transport_config(config);\n// now you can start ditto's sync\nditto.start_sync();\n\n",
"transport-sync-groups": "auto config = ditto::TransportConfig();\n\nconfig.enable_all_peer_to_peer();\nconfig.global.sync_group = 1234;\n\n// set the transport config\nditto.set_transport_config(config);\n// now you can start ditto's sync\nditto.start_sync();\n\n",
"network-listen": "auto config = ditto::TransportConfig();\n\nconfig.listen.tcp.enabled = true;\nconfig.listen.http.enabled = false;\nconfig.listen.tcp.interface_ip = \"0.0.0.0\";\nconfig.listen.tcp.port = 4000;\n\nditto.set_transport_config(config);\nditto.start_sync();\n\n",
Expand All @@ -154,7 +154,7 @@
"remove-id": "curl --location --request POST 'https://<CLOUD_ENDPOINT>/api/v3/store/write' \\\n--header 'X-DITTO-CLIENT-ID: AAAAAAAAAAAAAAAAAAAABQ==' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n \"commands\": [{\n \"method\": \"remove\",\n \"collection\": \"orders\",\n \"query\": \"_id == '<ID>'\"\n }]\n }'\n\n"
},
"javascript": {
"online-playground": "import { init, Ditto, Logger } from \"@dittolive/ditto\"\nLogger.minimumLogLevel = 'Debug'\nconst identity: Identity = { type: 'onlinePlayground', appID: '00000000-0000-4000-0000-000000000000', token: 'REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN' }\nconst ditto = new Ditto(identity, path)\nditto.startSync()\n\n",
"online-playground": "import { init, Ditto, Logger } from \"@dittolive/ditto\"\nconst identity: Identity = { type: 'onlinePlayground', appID: '00000000-0000-4000-0000-000000000000', token: 'REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN' }\nconst ditto = new Ditto(identity, path)\nditto.startSync()\n\n",
"online-playground-cloudSync": "const identity: Identity = {\n type: 'onlinePlayground',\n appID: '00000000-0000-4000-0000-000000000000',\n token: 'REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN',\n // Set to false to disable syncing with the cloud\n enableDittoCloudSync: true,\n}\nconst ditto = new Ditto(identity, path)\nditto.startSync()\n\n",
"offline-playground": "const identity: Identity = { type: 'offlinePlayground', appID: '00000000-0000-4000-0000-000000000000' }\nconst ditto = new Ditto(identity, path)\nditto.setOfflineOnlyLicenseToken(validLicense)\nditto.startSync()\n\n",
"datamodel": "const carsCollection = ditto.store.collection('cars')\n\n",
Expand Down Expand Up @@ -241,12 +241,12 @@
"query-args": "val foundDocs = ditto.store.collection(\"people\")\n .find(\"name == \\$args.name && age <= \\$args.age\", mapOf(\"name\" to \"max\", \"age\" to 32))\n\n",
"query-sort": "val sortedRedCars = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .sort(\"miles\", DittoSortDirection.Ascending)\n .exec()\n\n",
"query-limit": "val sortedAndLimitedRedCars = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .sort(\"miles\", DittoSortDirection.Ascending)\n .limit(100)\n .exec()\n\n",
"sync-basic": "try {\n ditto.startSync()\n}\ncatch (e: DittoError) {\n // handle error\n}\n\n",
"sync-basic": "try {\n ditto.startSync()\n} catch (e: DittoError) {\n // handle error\n}\n\n",
"sync-observe": "// --- DittoRegister live query to update UI\nval liveQuery = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .observeLocal { docs, event ->\n // Do something...\n }\n\n",
"sync-observe-local": "// --- Action somewhere in your application\nfun userDidInsertCar() {\n ditto.store.collection(\"cars\").upsert(mapOf(\n \"model\" to \"Ford\",\n \"color\" to \"black\"\n ))\n}\n\n// --- DittoRegister live query to update UI\nval observeLocalQuery = ditto.store.collection(\"cars\")\n .find(\"isSold == false\")\n .observeLocal { docs, event ->\n // Do something...\n}\n\n",
"subscribe": "// --- DittoRegister live query to update UI\nval subscription = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .subscribe()\n\n",
"online-playground": "try {\n val androidDependencies = DefaultAndroidDittoDependencies(context)\n val identity = DittoIdentity.OnlinePlayground(androidDependencies,\n appId = \"00000000-0000-4000-0000-000000000000\",\n token = \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\")\n DittoLogger.minimumLogLevel = DittoLogLevel.DEBUG\n val ditto = Ditto(androidDependencies, identity)\n ditto.startSync()\n ditto.close()\n} catch(e: DittoError) {\n Log.e(\"Ditto error\", e.message!!)\n}\n\n",
"offline-playground": "try {\n val androidDependencies = DefaultAndroidDittoDependencies(context)\n val identity = DittoIdentity.OfflinePlayground(androidDependencies, appId =\n \"00000000-0000-4000-0000-000000000000\")\n val ditto = Ditto(androidDependencies, identity)\n ditto.setOfflineOnlyLicenseToken(validLicense)\n ditto.startSync()\n} catch(e: DittoError) {\n Log.e(\"Ditto error\", e.message!!)\n}\n\n",
"online-playground": "try {\n val androidDependencies = DefaultAndroidDittoDependencies(context)\n val identity = DittoIdentity.OnlinePlayground(\n androidDependencies,\n appId = \"00000000-0000-4000-0000-000000000000\",\n token = \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\"\n )\n DittoLogger.minimumLogLevel = DittoLogLevel.DEBUG\n ditto = Ditto(androidDependencies, identity)\n ditto.startSync()\n} catch (e: DittoError) {\n Log.e(\"Ditto error\", e.message!!)\n}\n\n",
"offline-playground": "try {\n val androidDependencies = DefaultAndroidDittoDependencies(context)\n val identity = DittoIdentity.OfflinePlayground(androidDependencies, appId =\n \"00000000-0000-4000-0000-000000000000\")\n ditto = Ditto(androidDependencies, identity)\n ditto.setOfflineOnlyLicenseToken(validLicense)\n ditto.startSync()\n} catch(e: DittoError) {\n Log.e(\"Ditto error\", e.message!!)\n}\n\n",
"shared-key": "// This is just an example. You should use OpenSSL to generate a unique shared key for every application.\nval p256DerB64 = \"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgFUUrOkOH52QN+Rr6uDSDsk4hUTcD1eW4mT0UnGGptFehRANCAATJ3fG8TVLQcDwUV18BJJI8efK0hQAjzB3VJeYOVbfOlqnfukVId0V25r/abxwjD3HfHuPsCGEiefzzmkMbjPo9\"\nval androidDependencies = DefaultAndroidDittoDependencies(context)\nval identity = DittoIdentity.SharedKey(\"app\", p256DerB64, null)\nval ditto = Ditto(androidDependencies, identity)\nditto.setOfflineOnlyLicenseToken(validLicense)\n\n",
"transport-configurations": "val config = DittoTransportConfig()\n\n//Enable all peer to peer transports\nconfig.enableAllPeerToPeer()\n\n//Or enable/disable each transport separately\n//BluetoothLe\nconfig.peerToPeer.bluetoothLe.enabled = true\n//Local Area Network\nconfig.peerToPeer.lan.enabled = true\n//Wifi Aware\nconfig.peerToPeer.wifiAware.enabled = true\n\nditto.transportConfig = config\n\nditto.startSync()\n\n",
"transport-sync-groups": "val config = DittoTransportConfig()\n\n//Enable all peer to peer transports\nconfig.enableAllPeerToPeer()\nconfig.global.syncGroup = 1234U\n\nditto.transportConfig = config\n\nditto.startSync()\n\n",
Expand Down

0 comments on commit 4240bbc

Please sign in to comment.