Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var schema = new Schema({
- // ...
- views: [new Schema({
- userId: String,
- expired: Date
- })]
- });
- exports.Order = mongoose.model("Order", schema);
- Order.find({
- $and: [
- // other conditions
- { $or: [{"views.userId": { $ne: userId } }, { $and: [
- { "views.userId": userId },
- { "views.expired": { $gte: new Date()}}
- ]}]}
- ]
- }, function (err, data) {
- if (err) console.log(err);
- console.log(data);
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement