چله تابستون 🔥 چله تخفیف استثنایی راکت، این فرصت دیگه پیش نمیاد!
فرصت محدود، تعداد محدودسلام دوستان این مدل منه میخوام expires بشه
تو stackoverflow هم گشتم ولی هر روشی رو تست کردم بازم حذف نمیشه فیلدم از دیتابیس!
(1)
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const timestamps = require('mongoose-timestamp');
const testSchema = new Schema({
name : { type : String , createdAt: { type: Date, expires: '1m', default: Date.now }}
});
// testSchema.index({createdAt: 1},{expireAfterSeconds: 3600})
testSchema.plugin(timestamps);
module.exports = mongoose.model('Test' , testSchema , 'test');
(2)
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const timestamps = require('mongoose-timestamp');
const testSchema = new Schema({
name : { type : String , required : true}
});
testSchema.index({createdAt: 1},{expireAfterSeconds: 3600})
testSchema.plugin(timestamps);
module.exports = mongoose.model('Test' , testSchema , 'test');
(3)
> const mongoose = require('mongoose'); const Schema = mongoose.Schema;
> const timestamps = require('mongoose-timestamp');
>
> const testSchema = new Schema({ name : { type : String , required :
> true , index: { expires: 'expires: 3600' }}
>
> });
>
> testSchema.plugin(timestamps);
>
> module.exports = mongoose.model('Test' , testSchema , 'test');
این سه روش رو تست کردم اما جواب نمیده!
به navid کمک کنید تا مشکل خودش را حل کند؛ اینطور میتوانیم با هم پیشرفت کنیم.
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟