Reputation: 5029
I need to store and transfer some mongodb queries built in javascript for later execution in a back-end written in go language.
A few of these queries involve comparison with dates. In mongodb's shell, there is a specific format for performing queries with dates; with the ISODate
construct.
Is it possible to have a different construct, that is nicely translatable in pure JSON so that different systems that use mongodb can run the same query in a compatible way?
I already tried several queries that do not involve using special constructs such as ISODate
or JavaScript's native Date
object, but had not luck with it.
I also tried MongoDB Extended JSON as in: db.userStats.find({'Tmin': {$gt: { $date: '1999-12-31T23:00:00.000Z'} }})
, but it did not work.
Any ideas?
thanks!
Upvotes: 1
Views: 373
Reputation: 11671
There isn't a standard driver- or client-independent way to write down MongoDB queries in a human friendly form. Extended JSON is the "closest" thing but it's not understood by drivers. The best option is to cook up a format that works for your applications.
Upvotes: 1