如何将日期插入ArangoDB?
How to insert Date to ArangoDB?
我不明白ArangoDB 的日期存储是什么格式。
尝试以这种格式插入日期:
{"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'.
看起来 vibed JSON 模块在这个字符串上失败了,但是 Arango 使用什么格式?
{"name":"vasia","date":"2013-01-15"}
格式的字符串成功插入数据库,但我不明白它是作为文本插入还是作为日期对象插入?
我没有使用过 ArangoDB,但是 ArangoDB date documentation 建议你使用类似 DATE_TIMESTAMP("2013-01-15T14:19:09.522")
和/或 DATE_ISO8601("2013-01-15T14:19:09.522Z")
的东西。希望这有帮助。
Is it inserting as text or as
Date object?
作为文本,因为 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.
我不明白ArangoDB 的日期存储是什么格式。
尝试以这种格式插入日期:
{"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'.
看起来 vibed JSON 模块在这个字符串上失败了,但是 Arango 使用什么格式?
{"name":"vasia","date":"2013-01-15"}
格式的字符串成功插入数据库,但我不明白它是作为文本插入还是作为日期对象插入?
我没有使用过 ArangoDB,但是 ArangoDB date documentation 建议你使用类似 DATE_TIMESTAMP("2013-01-15T14:19:09.522")
和/或 DATE_ISO8601("2013-01-15T14:19:09.522Z")
的东西。希望这有帮助。
Is it inserting as text or as Date object?
作为文本,因为 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.