-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fix Schema constructor so that it picks up config values for the lounge object. #5
Comments
Would this set expiry for both the document and the reference? Currently it seems to set expiry you have to do so at the model as part of save() but the references don't get a similar expiry so the document disappears and the references linger. :( |
Hello, thanks for your comment. Can you elaborate some more on the use case and maybe provide some sample code. Not sure if it is this issue, but could be a different issue or missed feature. |
Sure; and my apologies in advance if this belongs elsewhere. Yours is the only ODM that seems to support expiry; which I need. var schema = lounge.schema({
id: {
type: String,
key: true,
generate: false,
refKeyCase: 'lower'
},
manufacturer: {
type: String,
index: true
},
type: String,
sku: {
invisible: true,
type: 'alias',
target: 'id'
}
}, {expiry: 60});
// setting expiry here has no effect on either the resulting model instances or their refs
schema.pre('save', function (next) {
this.type = this.modelName;
next();
});
var sku = new Sku({
id: 'sku8260387',
});
// setting expiry here will delete the model after 60 seconds, but the ref will remain indefinitely
sku.save({expiry:60}, function (err, result) {
if (err) throw err;
console.log(result);
}); |
Ok yes this is a missing feature (and possibly a bug). we can add something like Can you explain in more detail the schema and the intention of that schema, as it's not clear to me. What do you mean by ref? |
the schema was mostly a goof just to compare lounge to competing ODM libraries before I got too far down the path (no offense). I understand your confusion with "ref"... I didn't think about it at the time, but I stripped the schema down to the bare essentials to demonstrate the expiry issue and in doing so removed the indexed properties that would normally automatically create reference documents. I edited the previous comment to add one back ("manufacturer"). In this scenario, the persisted Sku model instance will expire and be purged from couchbase, but the reference document |
Right now when we do:
The config settings set in the
lounge
instance do not get applied to the constructor. We should be able to do this, so that config settings are applied.The text was updated successfully, but these errors were encountered: