Skip to content
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

How do I define a DTO field as int64 and mapped to MongoDB DateTime? #10

Closed
ns-wxin opened this issue Mar 14, 2023 · 1 comment
Closed

Comments

@ns-wxin
Copy link

ns-wxin commented Mar 14, 2023

I'm having difficulty finding an example to define a DTO field and map it to MongoDB as DateTime. The example in this repo doesn't have such field.

With a uint64, it's mapped a timestamp which is not quite what I want. I'm getting compiler error if I do the following complaining "DateTime" is not a defined type.

class MyGroup : public oatpp::DTO {
    DTO_INIT(FingerprintGroup, DTO)

    DTO_FIELD(String, _id);

    DTO_FIELD(String, fpGroupName);
    DTO_FIELD(String, status);
    DTO_FIELD(String, type);
    DTO_FIELD(Int32, version) = 0;
    DTO_FIELD(DateTime, created) = 0L;
    DTO_FIELD(DateTime, updated) = 0L;
};
@ns-wxin
Copy link
Author

ns-wxin commented Mar 14, 2023

Sorry, I figured out that I have to include <oatpp-mongo/bson/Types.hpp>

do using oatpp::mongo::bson::DateTime;

closing it.

@ns-wxin ns-wxin closed this as completed Mar 14, 2023
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

No branches or pull requests

1 participant