[MongoDB] MongoDB -- OS DateTime Conversion

[MongoDB] MongoDB -- OS DateTime Conversion

  
Forge Component
(7)
Published on 2017-02-24 by Barduino
7 votes
Published on 2017-02-24 by Barduino

When inserting documents into MongoDB with a Outsystems DateTime data, the Date/Time data is converted to String type.  The string is the correct representation of the DateTime value.

I am not a NET programmer and cannot load the MongoDB Extension code to review the conversions built in to the extension or possibly this is an issue with the JSON serializer.

Any help would be appreciated.


If the JSON serializer done by your code, try to debug the output of JSON serializer.

Hi Tony!  I would be happy to dig something up for you - can you tell me what it's breaking?

Harlin Setiadarma wrote:

If the JSON serializer done by your code, try to debug the output of JSON serializer.

The JSON Serializer is handling its part correctly.  It is taking a DateTime and either handling as Text or UNIX Timestamp depending on the property set for the function.  But when the MongoDB extension inserts into the MongoDB, there is no conversion to the MongoDB data type which is LongInteger.  Even if I use LongInteger for the list structure, it is being loaded into MongoDB as Integer.


Doug_inVA wrote:

Hi Tony!  I would be happy to dig something up for you - can you tell me what it's breaking?

The JSON Serializer is taking a DateTime and either handling as Text or UNIX Timestamp depending on the property set for the function.  But when the MongoDB extension inserts into the MongoDB, there is no conversion to the MongoDB data type which is LongInteger.  Even if I use LongInteger for the list structure, it is being loaded into MongoDB as Integer.  I cannot tell how the extension inserts the JSON into the collection and quite honestly, not sure that I could even if I could get to the .NET source code of the extension.


Hi Tony

I'm not sure exactly what is the issue.

I've created a date time field in the structure of the example (see the try now) and it seems to be sorting correctly inside Mongo,

The way it translated to mongoDB is done at the C# driver level.

Can you elaborate with a specific example?

Barduino wrote:

Hi Tony

I'm not sure exactly what is the issue.

I've created a date time field in the structure of the example (see the try now) and it seems to be sorting correctly inside Mongo,

The way it translated to mongoDB is done at the C# driver level.

ICan you elaborate with a specific example?

I see it works in the "Try Me" but when I reloaded the MongoDB application into my eSpace and published, the "Date" fields is not used.  I need to see how the date field is represented in the MongoDB, that is where I am having the issue.  I suspect it is being inserted as the text form of the DateTime not as a Long Integer representing the number of milliseconds since the Unix Epoch.