Skip to content

Types: Add DateTime support. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2020
Merged

Conversation

lganzzzo
Copy link
Member

Now BSON DateTime data type is supported.

  #include "oatpp-mongo/bson/Types.hpp"

  ...

  auto duration = std::chrono::system_clock::now().time_since_epoch();
  auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();

  collection.insert_one(createMongoDocument(
    oatpp::Fields<oatpp::Any>({
        {"time", oatpp::mongo::bson::DateTime(millis)}
    })
  ));

Inserted document:

_id: ObjectId("5f9b6ecb21a7da049662e7d2")
time: 2020-10-30T01:39:23.940+00:00

Links:

@lganzzzo lganzzzo merged commit ebfad69 into master Oct 30, 2020
@lganzzzo lganzzzo deleted the implement_datetime_datatype branch October 30, 2020 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant