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
Get a read-only snapshot of a document at the requested version.
281
+
282
+
*`collection`_(String)_
283
+
Collection name of the snapshot
284
+
*`id`_(String)_
285
+
ID of the snapshot
286
+
*`timestamp`_(number) [optional]_
287
+
The timestamp of the desired snapshot. The returned snapshot will be the latest snapshot before the provided timestamp. If `null`, the latest version is fetched.
239
288
*`callback`_(Function)_
240
289
Called with `(error, snapshot)`, where `snapshot` takes the following form:
241
290
@@ -267,7 +316,7 @@ Populate the fields on `doc` with a snapshot of the document from the server, an
267
316
fire events on subsequent changes.
268
317
269
318
`doc.ingestSnapshot(snapshot, callback)`
270
-
Ingest snapshot data. This data must include a version, snapshot and type. This method is generally called interally as a result of fetch or subscribe and not directly. However, it may be called directly to pass data that was transferred to the client external to the client's ShareDB connection, such as snapshot data sent along with server rendering of a webpage.
319
+
Ingest snapshot data. The `snapshot` param must include the fields `v` (doc version), `data`, and `type` (OT type). This method is generally called interally as a result of fetch or subscribe and not directly from user code. However, it may still be called directly from user code to pass data that was transferred to the client external to the client's ShareDB connection, such as snapshot data sent along with server rendering of a webpage.
271
320
272
321
`doc.destroy()`
273
322
Unsubscribe and stop firing events.
@@ -358,6 +407,27 @@ after a sequence of diffs are handled.
358
407
`query.on('extra', function() {...}))`
359
408
(Only fires on subscription queries) `query.extra` changed.
360
409
410
+
### Logging
411
+
412
+
By default, ShareDB logs to `console`. This can be overridden if you wish to silence logs, or to log to your own logging driver or alert service.
413
+
414
+
Methods can be overridden by passing a [`console`-like object](https://developer.mozilla.org/en-US/docs/Web/API/console) to `logger.setMethods`
415
+
416
+
```javascript
417
+
var ShareDB =require('sharedb/lib/client');
418
+
ShareDB.logger.setMethods({
419
+
info: () => {}, // Silence info
420
+
warn: () =>alerts.warn(arguments), // Forward warnings to alerting service
421
+
error: () =>alerts.critical(arguments) // Remap errors to critical alerts
422
+
});
423
+
```
424
+
425
+
ShareDB only supports the following logger methods:
426
+
427
+
-`info`
428
+
-`warn`
429
+
-`error`
430
+
361
431
362
432
## Error codes
363
433
@@ -422,3 +492,5 @@ The `41xx` and `51xx` codes are reserved for use by ShareDB DB adapters, and the
422
492
* 5018 - Required QueryEmitter listener not assigned
0 commit comments