You are not logged in.
Pages: 1
Hello,
I'm having issues updating a record to mongo using mORMot.
- Application loads data from mongoDB in to a variant.
- Makes some modifications.
- Writes the data back to the DB.
The problem is that after the update the various date fields within the record (which haven't been modified in the app), are no longer recognised as date types - they are strings.
We fixed this issue during import, using this:
var
data : variant;
buffer : string;
...
data := _JSon(RawUTF8(buffer), [dvoJSONParseDoNotTryCustomVariants]);
...
But it doesn't appear to work when writing back to the DB.
Any help would be appreciated!
Thanks!
Offline
It is highly depending on how you create the data.
If you use some plain _Json() content, you will only be transmitted JSON strings, not data.
This is as expected.
There is no schema involved, so there is no way of knowing the value type: there is no date/time type in JSON!
Use the DateToSQL() value to append the JSON_SQLDATE_MAGIC prefix to the string.
It will then be recognized as a date when converted back to BSON for MongoDB.
Offline
Thanks for the reply.
I'll have a look at using DateToSQL().
Offline
Pages: 1