From 153ec004e6ede832514833648884bab1586c351b Mon Sep 17 00:00:00 2001 From: Rae Mac <633012+okdistribute@users.noreply.github.com> Date: Sat, 24 Sep 2022 00:49:58 -0600 Subject: [PATCH] Remove findAll, fixes #285 --- snippets.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/snippets.json b/snippets.json index da6367b9a0..ee5d5d4bc0 100644 --- a/snippets.json +++ b/snippets.json @@ -57,7 +57,7 @@ "network-listen": "DITMutableTransportConfig *transportConfig = [[DITMutableTransportConfig alloc] init];\n[transportConfig.listen.tcp setEnabled:true];\n[transportConfig.listen.tcp setInterfaceIp:@\"0.0.0.0\"];\n[transportConfig.listen.tcp setPort:4000];\n[ditto setTransportConfig:transportConfig];\nNSError *err = nil;\n[ditto startSync:&err];\n\n", "network-multiple-transports": "DITMutableTransportConfig *transportConfig = [[DITMutableTransportConfig alloc] init];\n// 1. Enable Local Area Network Connections\n[transportConfig enableAllPeerToPeer];\n// 2. Listen for incoming connections on port 4000\n[transportConfig.listen.tcp setEnabled:true];\n[transportConfig.listen.tcp setInterfaceIp:@\"0.0.0.0\"];\n[transportConfig.listen.tcp setPort:4000];\n// 3. Connect explicitly to remote devices\n[transportConfig.connect.tcpServers addObject:@\"135.1.5.5:12345\"];\n[transportConfig.connect.tcpServers addObject:@\"185.1.5.5:12345\"];\n\n[ditto setTransportConfig:transportConfig];\nNSError *err = nil;\n[ditto startSync:&err];\n\n", "network-monitor-conditions": "// Setting up inside a ViewController\nDITIdentity *identity = [[DITIdentity alloc] initOnlinePlaygroundWithAppID:@\"REPLACE_WITH_APP_ID\" token:@\"REPLACE_WITH_PLAYGROUND_TOKEN\"];\nDITDitto *ditto = [[DITDitto alloc] initWithIdentity:identity];\nditto.delegate = self;\n[ditto startSync:nil];\n \n// Now you can observe real time changes to the transport conditions:\n@interface ViewController () \n\n@end\n\n@implementation ViewController\n\n- (void)transportConditionChanged:(enum DITTransportCondition)condition forSubsystem:(enum DITConditionSource)source {\n if (condition == DITTransportConditionBleDisabled) {\n NSLog(@\"BLE disabled\");\n } else if (condition == DITTransportConditionNoBleCentralPermission) {\n NSLog(@\"Permission missing for BLE\");\n } else if (condition == DITTransportConditionNoBlePeripheralPermission) {\n NSLog(@\"Permission missing for BLE\");\n }\n}\n\n@end\n\n", - "network-query-overlap-group": "NSString *const orders = @\"orders\";\n\n// The passenger only observes orders that they created\n[[[passenger.store collection:orders] find:@\"user_id==abc123\"] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render my orders in a list UI\n}];\n\n// Crew member devices observe all orders that everyone created\n[[[crewA.store collection:orders] findAll] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders in a list UI\n}];\n\n[[[crewB.store collection:orders] findAll] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders\n}];\n\n// Set up our query overlap group and priorities such that the crew members\n// will construct multihop connections with each other.\n[DITExperimental setQueryOverlapGroup:2 ditto:crewA];\n[DITExperimental setQueryOverlapGroup:2 ditto:crewB];\n\n// Query overlap groups should be set before startSync\n[crewA startSync:nil];\n[crewB startSync:nil];\n[passenger startSync:nil];\n\n", + "network-query-overlap-group": "NSString *const orders = @\"orders\";\n\n// The passenger only observes orders that they created\n[[[passenger.store collection:orders] find:@\"user_id==abc123\"] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render my orders in a list UI\n}];\n\n// Crew member devices observe all orders that everyone created\n[[[crewA.store collection:orders] find:@\"status == 'OPEN'\"] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders in a list UI\n}];\n\n[[[crewB.store collection:orders] find:@\"status == 'OPEN'\"] observe:^(NSArray *docs, DITLiveQueryEvent *event) {\n // render all orders\n}];\n\n// Set up our query overlap group and priorities such that the crew members\n// will construct multihop connections with each other.\n[DITExperimental setQueryOverlapGroup:2 ditto:crewA];\n[DITExperimental setQueryOverlapGroup:2 ditto:crewB];\n\n// Query overlap groups should be set before startSync\n[crewA startSync:nil];\n[crewB startSync:nil];\n[passenger startSync:nil];\n\n", "network-set-priority": "[DITExperimental setPriority:DITConnectionPriorityHigh\n forQueryOverlapGroup:2 ditto:crewA];\n[DITExperimental setPriority:DITConnectionPriorityHigh\n forQueryOverlapGroup:2 ditto:crewB];\n\n", "evict": "NSArray *evictedIDs = [[collection find:@\"make == 'Honda'\"] evict];\n\n" }, @@ -215,8 +215,8 @@ "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-observe": "// --- DittoRegister live query to update UI\nval liveQuery = ditto.store.collection(\"cars\")\n .findAll()\n .observe { 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 .findAll()\n .observeLocal { docs, event ->\n // Do something...\n}\n\n", + "sync-observe": "// --- DittoRegister live query to update UI\nval liveQuery = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .observe { 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, appID = \"00000000-0000-4000-0000-000000000000\", token = \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\")\n val 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 = AndroidDittoDependencies(context)\n val identity = DittoIdentity.OfflinePlayground(androidDependencies, appID = \"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", @@ -225,7 +225,7 @@ "network-listen": "val transportConfig = DittoTransportConfig()\ntransportConfig.connect.tcpServers.add(\"135.1.5.5:12345\")\ntransportConfig.connect.tcpServers.add(\"185.1.5.5:12345\")\nditto.startSync()\n\n", "network-multiple-transports": "val transportConfig = DittoTransportConfig()\n// 1. Enable All Peer to Peer Connections\ntransportConfig.enableAllPeerToPeer()\n// 2. Listen for incoming connections on port 4000\ntransportConfig.listen.tcp.enabled = true\ntransportConfig.listen.http.enabled = false\ntransportConfig.listen.tcp.interfaceIp = \"0.0.0.0\"\ntransportConfig.listen.tcp.port = 4000\n// 3. Connect explicitly to remote devices\ntransportConfig.connect.tcpServers.add(\"135.1.5.5:12345\")\ntransportConfig.connect.tcpServers.add(\"185.1.5.5:12345\")\n\nditto.startSync()\n\n", "network-monitor-conditions": "// ... Setting up inside an Activity\nval androidDependencies = DefaultAndroidDittoDependencies(applicationContext)\nval ditto = Ditto(androidDependencies, DittoIdentity.OnlinePlayground(androidDependencies, appID = \"REPLACE_WITH_APP_ID\", token = \"REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN\"))\nditto.callback = this\nditto.startSync()\n\n// Now you can observe real time changes to the transport conditions:\n\nclass MainActivity : AppCompatActivity(), DittoCallback {\n\n override fun transportConditionDidChange(transportId: Long, condition: TransportCondition) {\n var toastText: String? = null\n if (condition == TransportCondition.TRANSPORT_CONDITION_BLE_DISABLED) {\n toastText = \"BLE disabled\"\n } else if (condition == TransportCondition.TRANSPORT_CONDITION_NO_BLE_CENTRAL_PERMISSION) {\n toastText = \"Permission missing for BLE\"\n } else if (condition == TransportCondition.TRANSPORT_CONDITION_NO_BLE_PERIPHERAL_PERMISSION) {\n toastText = \"Permission missing for BLE\"\n }\n toastText?.let {\n Handler(mainLooper).post {\n Toast.makeText(this, it, Toast.LENGTH_LONG).show()\n }\n }\n }\n}\n\n", - "network-query-overlap-group": "// The passenger only observes orders that they created\npassenger.store.collection(\"orders\").find(\"user_id==abc123\").observe({ docs, event ->\n // render passenger orders in a list UI\n})\n\n// Crew member devices observe all orders that everyone created\ncrewA.store.collection(\"orders\").findAll().observe({ docs, event ->\n // render all orders in a list UI\n})\ncrewB.store.collection(\"orders\").findAll().observe({ docs, event ->\n // render all orders in a list UI\n})\n\nDittoExperimental.setQueryOverlapGroup(2u, crewA)\nDittoExperimental.setQueryOverlapGroup(2u, crewB)\n\ncrewA.startSync()\ncrewB.startSync()\npassenger.startSync()\n\n", + "network-query-overlap-group": "// The passenger only observes orders that they created\npassenger.store.collection(\"orders\").find(\"user_id==abc123\").observe({ docs, event ->\n // render passenger orders in a list UI\n})\n\n// Crew member devices observe orders that are open \ncrewA.store.collection(\"orders\").find(\"status == 'OPEN'\").observe({ docs, event ->\n // render all orders in a list UI\n})\ncrewB.store.collection(\"orders\").find(\"status == 'OPEN'\").observe({ docs, event ->\n // render all orders in a list UI\n})\n\nDittoExperimental.setQueryOverlapGroup(2u, crewA)\nDittoExperimental.setQueryOverlapGroup(2u, crewB)\n\ncrewA.startSync()\ncrewB.startSync()\npassenger.startSync()\n\n", "network-set-priority": "DittoExperimental.setPriorityForQueryOverlapGroup(DittoConnectionPriority.High, 2u, crewA)\nDittoExperimental.setPriorityForQueryOverlapGroup(DittoConnectionPriority.High, 2u, crewB)\n\n", "remove-id": "coll.findByID(docID).remove()\n\n", "remove-query": "val removedDocIDs = coll.find(\"make == 'Honda'\").remove()\n\n" @@ -251,9 +251,9 @@ "query-sort": "List sortedRedCars = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .sort(\"miles\", DittoSortDirection.Ascending)\n .exec();\n\n", "query-limit": "List 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} catch(DittoError e) {\n // handle error\n}\n\n", - "sync-observe": "// --- Register live query to update UI\nDittoLiveQuery liveQuery = ditto.store.collection(\"cars\")\n .findAll()\n .observe((docs, event) -> {\n // Do something...\n });\n\n", - "subscribe": "// --- Register live query to update UI\nDittoSubscription subscription = ditto.store.collection(\"cars\")\n .findAll()\n .subscribe();\n\n", - "sync-observe-local": "// --- Action somewhere in your application\nMap content = new HashMap<>();\ncontent.put(\"model\", \"Ford\");\ncontent.put(\"color\", \"black\");\nditto.store.collection(\"cars\").upsert(content);\n\n// --- Register live query to update UI\nDittoLiveQuery liveQueryLocal = ditto.store.collection(\"cars\")\n .findAll()\n .observeLocal((docs, event) -> {\n // Do something...\n });\n\n", + "sync-observe": "// --- Register live query to update UI\nDittoLiveQuery liveQuery = ditto.store.collection(\"cars\")\n .find(\"color == 'red'\")\n .observe((docs, event) -> {\n // Do something...\n });\n\n", + "subscribe": "// --- Register live query to update UI\nDittoSubscription subscription = ditto.store.collection(\"cars\")\n .find(\"!isSold\")\n .subscribe();\n\n", + "sync-observe-local": "// --- Action somewhere in your application\nMap content = new HashMap<>();\ncontent.put(\"model\", \"Ford\");\ncontent.put(\"color\", \"black\");\nditto.store.collection(\"cars\").upsert(content);\n\n// --- Register live query to update UI\nDittoLiveQuery liveQueryLocal = ditto.store.collection(\"cars\")\n .find(\"owner == 'Susan'\")\n .observeLocal((docs, event) -> {\n // Do something...\n });\n\n", "shared-key": "// This is just an example. You should use OpenSSL to generate a unique shared key for every application.\nString p256DerB64 = \"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgFUUrOkOH52QN+Rr6uDSDsk4hUTcD1eW4mT0UnGGptFehRANCAATJ3fG8TVLQcDwUV18BJJI8efK0hQAjzB3VJeYOVbfOlqnfukVId0V25r/abxwjD3HfHuPsCGEiefzzmkMbjPo9\";\nDefaultAndroidDittoDependencies androidDependencies = new DefaultAndroidDittoDependencies(this.context);\nDittoIdentity identity = new DittoIdentity.SharedKey(androidDependencies, \"app\", p256DerB64);\nDitto ditto = new Ditto(androidDependencies, identity);\ntry {\n ditto.setOfflineOnlyLicenseToken(validLicense);\n} catch(DittoError e) {\n //handle error\n}\n\n", "online-playground": "DittoDependencies androidDependencies = new DefaultAndroidDittoDependencies(this.context);\nDittoIdentity identity = new DittoIdentity.OnlinePlayground(androidDependencies, \"00000000-0000-4000-0000-000000000000\", \"YOUR_PLAYGROUND_TOKEN_HERE\");\nDitto ditto = new Ditto(androidDependencies, identity);\n\ntry {\n ditto.startSync();\n} catch(DittoError e) {\n //handle error\n}\n\n", "offline-playground": "DittoIdentity identity = new DittoIdentity.OfflinePlayground(androidDependencies, \"00000000-0000-4000-0000-000000000000\");\nDitto ditto = new Ditto(androidDependencies, identity);\ntry {\n ditto.setOfflineOnlyLicenseToken(validLicense);\n} catch(DittoError e) {\n //handle error\n}\ntry {\n ditto.startSync();\n} catch(DittoError e) {\n //handle error\n}\n\n",