You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5ef8078
Browse filesBrowse the repository at this point in the historyBrowse files
console.log(String.format(<span class="hljs-string">"saved user document %s"</span>, doc.getString(<span class="hljs-string">"name"</span>)));
255
-
}
256
-
}
257
-
});
258
-
}
259
-
<div class="paragraph">
260
-
<p>At the <strong>local</strong> level this operation is still transactional: no other <code>Database</code> instances, including ones managed by the replicator can make changes during the execution of the block, and other instances will not see partial changes.
261
-
But Couchbase Mobile is a distributed system, and due to the way replication works, there’s no guarantee that Sync Gateway or other devices will receive your changes all at once.</p>
262
-
</div>
263
-
-->
231
+
The following example persists a few documents in batch:
264
232
265
-
## Blobs
233
+
```typescript
234
+
awaitthis.database.inBatch(() => {
235
+
for (let sdk ofsdkDataToLoad) {
236
+
let doc =newMutableDocument()
237
+
.setNumber('version', sdk.version)
238
+
.setString('type', sdk.type)
239
+
.setString('company', sdk.company);
240
+
241
+
this.database.save(doc);
242
+
}
243
+
});
244
+
```
266
245
267
-
Storing large data, such as images.
246
+
At the <strong>local</strong> level this operation is still transactional: no other <code>Database</code> instances, including ones managed by the replicator can make changes during the execution of the block, and other instances will not see partial changes. But Couchbase Mobile is a distributed system, and due to the way replication works, there’s no guarantee that Sync Gateway or other devices will receive your changes all at once.
268
247
269
-
*Not yet supported.* Please [reach out](https://ionicframework.com/enterprise/contact) if you need this feature.
248
+
## Blobs
270
249
271
-
<!--
272
-
We’ve renamed "attachments" to "blobs".
273
-
The new behavior should be clearer too: a <code>Blob</code> is now a normal object that can appear in a document as a property value.
274
-
In other words, you just instantiate a <code>Blob</code> and set it as the value of a property, and then later you can get the property value, which will be a <code>Blob</code> object.
275
-
The following code example adds a blob to the document under the <code>avatar</code> property.</p>
250
+
Used to store large data, such as images.
251
+
252
+
The following code example adds a blob to the document under the <code>avatar</code> property.
276
253
277
254
```typescript
278
255
let is =getAsset("avatar.jpg");
@@ -302,15 +279,10 @@ That key can be used to retrieve the <code>Blob</code> object at a later time.
302
279
303
280
When a document is synchronized, the Couchbase Lite replicator will add an <code>_attachments</code> dictionary to the document’s properties if it contains a blob.
304
281
A random access name will be generated for each <code>Blob</code> which is different to the "avatar" key that was used in the example above.
305
-
On the image below, the document now contains the <code>_attachments</code> dictionary when viewed in the Couchbase Server Admin Console.
306
282
307
283
A blob also has properties such as <code>"digest"</code> (a SHA-1 digest of the data), <code>"length"</code> (the length in bytes), and optionally <code>"content_type"</code> (the MIME type).
308
284
The data is not stored in the document, but in a separate content-addressable store, indexed by the digest.
309
285
310
-
This <code>Blob</code> can be retrieved on the Sync Gateway REST API at <a href="http://localhost:4984/justdoit/user.david/blob_1" class="bare">http://localhost:4984/justdoit/user.david/blob_1</a>.
311
-
Notice that the blob identifier in the URL path is "blob_1" (not "avatar").
312
-
-->
313
-
314
286
## Query
315
287
316
288
Database queries are based on expressions, of the form "return __ from documents where __, ordered by __", with semantics based on Couchbase’s N1QL query language.
0 commit comments