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
@@ -322,272 +321,6 @@ after a sequence of diffs are handled.
322
321
(Only fires on subscription queries) `query.extra` changed.
323
322
324
323
325
-
326
-
<!-- Old docs from LiveDB:
327
-
328
-
## Using ShareDB
329
-
330
-
### Creating documents
331
-
332
-
To create a document, you need to submit a create operation to the
333
-
document to set its type. In sharedb's world, a document doesn't exist until it
334
-
has a type set.
335
-
336
-
A create operation looks like this: `{create:{type:TYPE, [data:INITIAL DATA]}, [v:VERSION]}`. The type should be something accessible in the map returned by require('ottypes'), for example `json0` or `http://sharejs.org/types/textv1`. Specifying initial data is optional. If provided, it is passed to the type's `create()` method. This does what you expect - for JSON documents, pass your initial object here. For text documents, pass a string containing the document's contents. As with all operations, the version is optional. You probably don't want to specify the version for a create message.
337
-
338
-
To submit any changes to documents, you use `sharedb.submit(cName, docName, opData, callback)`.
It calls your callback with `(err, snapshot, stream)`, giving you both the current document snapshot and the stream of operations from the current version.
529
-
530
-
#### Bulk Subscribe
531
-
532
-
If you want to subscribe to multiple documents at once, you should call
533
-
`bulkSubscribe(request, callback)`. The bulk subscribe request is a map from
534
-
cName -> map from docName -> version. For example, `{colors: {red:5, blue:6,
535
-
green:0}}`. The response is a map from cName -> map from docName -> stream.
536
-
For example, `{colors: {red:<stream>, blue:<stream>, green:<stream>}}`.
537
-
bulkSubscribe will either return a stream for all requested objects or (if
538
-
there was an error), none of them.
539
-
540
-
Again, remember to call `stream.destroy()` on all streams returned by bulk
541
-
subscribe when you're done with them.
542
-
543
-
544
-
### Queries
545
-
546
-
ShareDB supports running live queries against the database. It can re-run queries when it suspects that a query's results might have changed - and notify the caller with any changes to the result set.
547
-
548
-
This is incredibly inefficient and I want to completely rewrite / rework them. For now, I recommend against using live bound queries in a production app with a decent load. I'll document them when I'm happier with them.
549
-
550
-
551
-
### Projections
552
-
553
-
ShareDB supports exposing a *projection* of a real collection, with a specified
554
-
(limited) set of allowed fields. Once configured, the projected collection
555
-
looks just like a real collection - except documents only have the fields
556
-
you've requested.
557
-
558
-
Operations (gets, queries, sets, etc) on the fake collection work, but you only
559
-
see a small portion of the data. You can use this to drop server & db load
560
-
dramatically and speed up page times. Its similar to SQL VIEWs. For now, this
561
-
only works on JSON documents. (I don't know what it would look like for text
562
-
documents).
563
-
564
-
For example, you could make a `users_limited` projection which lets users view
565
-
each other's names and profile pictures, but not password hashes. You would
## Is it possible to completely delete documents from the db?
4
+
5
+
No, it is not possible to use the ShareDB API to fully delete data. In addition, the operation log is kept forever by default.
6
+
7
+
Maintaining persistence of snapshots and ops means that ShareDB can correctly deal with all cases where ops have been removed. Permanently removing the snapshot document could result in a corrupt state in some edge cases by not maintaining the current document version, which must be incremented on each commit. As well, if you delete ops and then a client reconnects needing those ops, you will break that client and it will be unable to submit any pending changes or bring itself up to date from its current state. If your usecase calls for complete deletion of operations, you'll need to ensure that no clients will ever need them again or deal with the error appropriately.
8
+
9
+
You can currently delete from your persistent datastore directly. For example, if you're using MongoDB you can delete the data by connecting to Mongo directly, not via the ShareDB API. If you do delete snapshot data, be sure that you delete not just the document snapshot but all operations associated with that document. Having operations with no corresponding snapshot would result in a corrupt state.
0 commit comments