[CXX-1336] Find with date Created: 09/May/17 Updated: 11/Sep/19 Resolved: 10/May/17 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Documentation |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Trivial - P5 |
| Reporter: | Denis Bip | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Hi! Is it possible to create query that uses mongo-server-side date? For example find } |
| Comments |
| Comment by David Golden [ 10/May/17 ] |
|
Hmm. This sounds like an "XY Problem". You can find out the server's localtime via the ismaster command. However, I'm concerned that whatever use you have in mind is likely to lead to a problem. The server's clock is no more reliable than the client's clock and may be less so in way, as primary failover will give a different server with a completely different clock. I'm going to close this ticket, and I encourage you to discuss your use case on the mongodb-user list for broader feedback from MongoDB engineers and the community. |
| Comment by Denis Bip [ 10/May/17 ] |
|
That uses client-side clock, not server-side. That may be different. For example: server time 2017-02-10 00:00:00, client time 2017-02-10 00:02:00...If I run somthing like {"$gt": CURRENT_TIME - 1 min}then I get {"$gt": "2017-02-10 00:01:00"}, but that not what I want - {"$gt": "2017-02-09 29:59:00"}. If it is not possible, how to "find" server side current_date? |
| Comment by David Golden [ 09/May/17 ] |
|
Hi, Denis. You can query dates with the bsoncxx::types::b_date type. You might want to see one of our test files for examples working with system_clock::now(). Please look at src/bsoncxx/test/bson_b_date.cpp and let me know if that gives you enough information to work with. |