Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

current date in mongodb

1. Date() returns the current date as a string in mongosh.
2. new Date() returns the current date as a Date object

db.products.updateOne(
   { _id: 1 },
   {
     $set: { item: "apple" },
     $setOnInsert: { dateAdded: new Date() }
   },
   { upsert: true }
)
Comment

PREVIOUS NEXT
Code Example
Javascript :: element remove class 
Javascript :: Get size of a View in React Native 
Javascript :: electron get printer list 
Javascript :: wait for promise javascript 
Javascript :: math power javascript 
Javascript :: get all matches regex javascript 
Javascript :: delete element javascript 
Javascript :: Start Express Properly 
Javascript :: javascript between 
Javascript :: .text javascript 
Javascript :: http header express 
Javascript :: js map size 
Javascript :: javascript include property array object 
Javascript :: is undefined false in javascript 
Javascript :: backbone js cdn 
Javascript :: $.post javascript 
Javascript :: yup string date schema validation 
Javascript :: icomoon react native 
Javascript :: js binary 
Javascript :: make multiple api call using promise.all 
Javascript :: convert namednodemap to object 
Javascript :: callback function 
Javascript :: split string to char js 
Javascript :: json api 
Javascript :: remove eslint check react native 
Javascript :: javascript array slice 
Javascript :: anime.js 
Javascript :: load data from json server into html using jquery 
Javascript :: javascript var,let,const compare 
Javascript :: javascript remainder function 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =