How to insert Date to ArangoDB?

3.9k Views Asked by At

I can't understand what format use ArangoDB for date storage. Attempt to insert date in such format: {"name": "vasia", "date": date("2013-01-15")}

std.json.JSONException@C:\vibe-d-0.7.24\source\vibe\data\json.d(1116): (1): Error: Expected valid JSON token, got 'date("2013-0'.

It's look like vibed JSON module fail on this string, but what format use Arango?

String in format {"name":"vasia","date":"2013-01-15"} inserting in DB successfully, but I can't understand is it's inserting as text or as Date object?

2

There are 2 best solutions below

0
On BEST ANSWER

Is it inserting as text or as Date object?

As text, because ArangoDB only supports JSON data types. JSON doesn't have a Date type, so dates are usually encoded as strings. How you actually do that is up to you, but since you're using D, I suggest you use Date.toISOExtString. For a few other options, see this question.

6
On

I haven't used ArangoDB, but the ArangoDB date documentation suggest you use something like DATE_TIMESTAMP("2013-01-15T14:19:09.522") and / or DATE_ISO8601("2013-01-15T14:19:09.522Z"). Hope this helps.