Query to get last X minutes data with Mongodb

前端 未结 4 1629
有刺的猬
有刺的猬 2020-12-04 16:11

I\'m beginning with mongodb, and I\'m trying to query my db that have this document format:

{ \"_id\" : ObjectId(\"520b8b3f8bd94741bf006033\"), \"value\" : 0         


        
4条回答
  •  北海茫月
    2020-12-04 16:25

    you can access the data of current timestamp from mongodb using nodejs

     const collection1 = dbo.collection('customers');
        var dateq = new Date();
          collection1.find({    "Timestamp" : { $gt: new Date(dateq.getTime() - 6000)}  
        }).toArray(function(err , docs){   
        console.log(docs);
        }
    

    code end

提交回复
热议问题