-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Renaming documents #143
Comments
I had to implement something similar. My solution was to assign each document a permanent id, generated using node-uuid, then have the "name" of the document be a mutable property. |
Thanks for confirming, that's what I'm going to do. |
I'm using it on the client, and depending on its randomness for avoiding collisions. |
I was just going to ask how one could efficiently be notified about filename changes in such a scenario and was all excited when I found out about the undocumented |
FWIW I added documentation for projections in the pending PR #154 Perhaps this issue can be closed? If not, can you clarify the exact issue with ShareDB? |
In the documentation you mention |
@nickasd Thanks a ton for the close reading! I went back and fixed that error re: different signatures. I believe, just like with real collections, if you want to be notified when any document changes, you'll need to subscribe to each and every individual document individually, the use |
You're welcome! And thanks for your suggestions. |
Right, it seems like there should be another way that's more efficient. If you use a projection with just the name field, only the name field will be loaded into memory for each document, and I think you can use the But still, it could be a lot of documents. Have you considered using the middleware? You can trigger some code any time a name change flows through the system by adding middleware that checks ops. sharedb.use('apply', (request, done) => {
console.log(request.op);
if(isNameChange(request.op)){
console.log("name changed");
}
done();
}); I'm not sure how this would play out with your use case, but it's one option for listening for changes. |
By using the projection I'm able to get all the filenames, but the problem is that in a projection subscription there are no events signalling when a name changes (as opposed to collection subscriptions), only the 'ready' event is fired. |
@nateps @rkstedman @josephg [issue tending note] I think this issue can be closed, as it's a question on how to use ShareDB, not a feature request or bug with ShareDB itself. |
Thanks @curran! |
Thanks @rkstedman ! |
Hi and thank you so much for this awesome library. I was wondering whether it would be possible to implement some kind of file manager, so that a client can subscribe to a collection named "files" and get updates whenever a document is added or removed. What is apparently missing is the ability to rename a document. Could this feature be added to a future release or should I store each document's filename as a property in the JSON object?
The text was updated successfully, but these errors were encountered: