These are chat archives for Automattic/mongoose

11th
Oct 2017
KARTHIKEYAN A
@karthikeyana__twitter
Oct 11 2017 04:14
var cronJob = require('cron').CronJob;    
var job = new cronJob({ 
    cronTime:'* * * * * 0-6', 
    onTick: function(){
        var my_date = new Date();
        var tomorrow_date = my_date.getFullYear() + "-" + ('0'+(my_date.getMonth()+1)) + "-" + (my_date.getDate()+1)
        var condition = [{},{$set: {'plannedDeliveryDate' :tomorrow_date +'T00:00:00.000Z'}}]
        dbQuery.updateMany(orderModel, condition, function(err, result){
              if(result.nModified == result.n) console.log(err, result)
          })
    },
    start:true,
    timeZone:'Asia/Kolkata'
});
job.start();
@muhammad786 try this one
parthi2929
@parthi2929
Oct 11 2017 07:45
Any simple example how do I use mongoose models defined in one place, and use in other modules?
parthi2929
@parthi2929
Oct 11 2017 07:53
In an example I am referring, they are defining mongoose model in a db.js file as below
```mongoose.model( 'User', userSchema );
mongoose.model( 'User', userSchema );
And in module that they need to use, they just do this:
```
var User = mongoose.model( 'User' );
var newuser=new User();
how can they use like this without export is what I am failing to understand.
Jemli Fathi
@jemliF
Oct 11 2017 09:36
@vladotesanovic I will need to do extra find, a good solution though
Do the enum array have a limit size
nationality: { type: String, enum: countries }
where countries is an array of countries
seltsam23
@seltsam23
Oct 11 2017 13:40
Hi there, lovely programmer-friends.
Does anyone have a best practise on storing orders with/for collections? Use case would be for lets say a toplist. Each Item on the list is a document in the collection. Now, how to store the position/order of the individual elements? In the Documents itself, or outside? How to update them? Would love to have your opinion.