Search code examples
jsondatedarangodbvibed

How to insert Date to ArangoDB?


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?


Solution

  • 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.