Skip to content
Advertisement

Tag: mongodb

Node JS + Mongo DB: ValidationError: User validation failed: username: Path `username` is required because it force replaces the field

I am trying to save my data to a mongodb server but somehow it force replaces the first variable as id so it is throwing the above mentioned error. in router code I am doing console.log(req.body,cred) and here is the result I get: { emailAddress: ‘test@gmail.com’, password: ‘123456’, id: ‘6070cbd7c603550ac4385485’ } { _id: 6078c61277453c2170d7e177, password: ‘123456’, id: ‘6070cbd7c603550ac4385485’ } Can

query mongoDb to substract timestamp

I want a query to subtract day from a Date. I test this: {“lastSeen”: { “$gte”: {“$date”: { $subtract: [ “$date”, 1616000000 ] }}}} But doesn’t work. I have this error on Gamesparks. Error parsing JSON. Please use valid JSON, including double-quotes on object keys. Any ideas. Thank you. Answer As this is a JSON file, you will need to

Advertisement