Repository navigation
Conversation
alecgibson
left a comment
There was a problem hiding this comment.
I'm curious; what's the use-case here? Should we add a utility method to Doc?
|
|
||
| {: .warn } | ||
| This method is generally called internally as a result of [`fetch()`](#fetch) or [`subscribe()`](#subscribe), and not directly from consumer code. Consumers *may* want to use this method to ingest data that was transferred to the client externally to the client's ShareDB connection. | ||
| This method is generally called internally as a result of [`fetch()`](#fetch) or [`subscribe()`](#subscribe), and not directly from consumer code. Consumers *may* want to use this method to ingest data that was transferred to the client externally to the client's ShareDB connection. To generate a snapshot from a fetched `Doc`, you can do the following: `const snapshot = { v: doc.version, data: doc.data, type: doc.type }`. |
There was a problem hiding this comment.
I think this isn't quite correct:
doc.typeis anobjectsnapshot.typeis astring(doc.type.uri)
There was a problem hiding this comment.
The other thing you could do is just cross-link to the Snapshot docs
|
@alecgibson Thanks for reviewing!
The use case:
In general, the need is to derive a well formed snapshot from an already fetched Doc (on the server), so that it can be passed into It's also expressed in the existing comment: "... ingest data that was transferred to the client externally to the client's ShareDB connection."
Yes please! That would be amazing. This would have the added benefit of being covered by tests, which would be really nice. |
|
Oh hey! I have some public code I can reference as a concrete use case:
This is all very WIP so bear with me. I hope what I'm trying to do makes sense. Thanks! |
|
Closing in favor of #508. |
Greetings,
I was attempting to use
ingestSnapshotby generating the snapshot on the server and sending it to the client, and I realized that the best documentation for how to create that actualsnapshotobject were found in the comments thread of this issue: #254I tried to find in the codebase where the
snapshotobject is constructed by looking into thedoc.fetchinternals, but could not find it. So I figured I would contribute this small documentation change.