mongoosejs / mongoose-ttl Goto Github PK
View Code? Open in Web Editor NEWProvides time-to-live support for Mongoose
Home Page: http://aheckmann.github.com/mongoose-ttl
License: MIT License
Provides time-to-live support for Mongoose
Home Page: http://aheckmann.github.com/mongoose-ttl
License: MIT License
I need to be informed if a document is removed from the database using the ttl reaper. But the middleware events don't get triggered at the moment.
I have to delete after 5 minutes when verified filed is false. Then how can I use this plugin?
I am using this NPM package; when I run my Node file, I get:
DeprecationWarning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.
I'm sure that it's not my problem. Could you please make changes to that?
This is my schema:
const ChatMessage = new Schema({
user: {type: ObjectId, ref: 'User', required: true},
device: {type: ObjectId, ref: 'Device', required: true},
agent: {type: Agent, required: false},
text: {type: String, required: true},
direction: {type: String, required: true, enum: _.values(constants.chatMessage.directions)},
date: {type: Date, required: true},
}, {collection: 'chat_messages'});
ChatMessage.plugin(ttl, {
ttl: 7776000000, // 90 days
interval: 86400000, // 24 hours
});
This is the query its being generated when I try to list chat messages:
Mongoose: chat_messages.find({ __ttl: { '$gt': new Date("Tue, 21 Nov 2017 04:33:35 GMT") }, device: ObjectId("59f01fdf0b2b4b71ffe0d24c"), user: ObjectId("59f01fde0b2b4b71ffe0d24b") }, { sort: { date: -1 }, fields: {} })
This query was executed at the same time of "$gt". Why this is happening?
Is there a way to call an callback function when one document have to leave?
Package MS has a Regular Expression Denial of Service Issue which has been patched in >0.7.0 You can read more about the issue here
An easy fix is to upgrade to 0.7.0^ on ms
(node:8148) DeprecationWarning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.