Setting expiration using Ottoman


#1

Is there currently a way to set the expiration of a document at time of creation (save) using Ottoman? I’ve been trying to look for documentation on it and haven’t found anything.

My use case for this is implementing sessions that expire after an hour. Appreciate the help!


#2

@brett19 Sorry to loop you in here, figured you might know more about Ottoman to get an answer on this.


#3

Hey @justin.laveroni,

Have you tried something like this?:

model.save({ "expiry": 3600 }, (error, result) => {});

It should take the same options as found in the vanilla SDK here:

http://docs.couchbase.com/sdk-api/couchbase-node-client-2.4.5/Bucket.html#insert__anchor

Let me know if that works for you.

Best,


#4

Hi @nraboy,
thanks to your videos, I’m using Ottoman to model my data.
now I want to Develop a User Profile Store and Session Store with Node.js and use Ottoman to make my model.
1- Is it needed to model sessions store in ottoman?
var SessionModel = ottoman.model(“Session”, {
pid: “string”
});
2- how to set {expiry:3600}?
I implemented your suggested above approach, but I’m getting this error:
TypeError: callback is not a function


#5

Pulling @brett19 into this as he is the engineer that created Ottoman.