fogine / couchbase-odm

CouchbaseODM is a promise-based Node.js ODM for Couchbase
https://fogine.github.io/couchbase-odm
MIT License
12 stars 3 forks source link

RefDocs are not deleted upon `remove` call #24

Closed mreis92 closed 7 years ago

mreis92 commented 7 years ago

What you are doing?

Call remove on an instance (any instance of a model)

Model.getById(id).then((model) => {
    return model.remove();
});

What do you expect to happen?

The document referenced by id to be removed, as well as every refDocs created.

What is actually happening?

Only the document being referenced is being deleted

Couchbase SDK version: 2.2.2 Couchbase Server version: 4.6.0 Community (Developer preview) CouchbaseODM version/branch: master

Hey there! I've been going through the documentation, and there's no reference to whether the refDocs are removed or not... If this is a feature rather than a bug, do you any suggestions on how to get pass this? Thanks!

fogine commented 7 years ago

Hello @mreis92 there is actually destroy method for that. The ModelInstance.remove is inherited from the Document prototype object method and indeed, by design, it does not remove any other documents except the main one. I should have documented the inherited methods of Document prototype further. Will do it in official 2.0.0 release with couple of more upcoming guides. Thanks for letting me know.

Feel free to message me on gitter with any related questions.