Dates at couchdb

How do you insert dates in couchdb? How are the lines?

I have couchdb-1.0.3.

1.

I have done this:

$ curl -X PUT 127.0.0.1:5984/misc/doc1  -d '{"date":"2011-13-01T17:30:12+01:00"}'

It works, but this date does not exist.

2.

I thought I should have done this:

$ curl -X PUT 127.0.0.1:5984/misc/doc1  -d '{"date":new Date("2011-12-01)}'

But this is not valid JSON.

3.

When I use this format,

$ curl -X PUT 127.0.0.1:5984/misc/doc1  -d '{"date":"2011/12/01 00:00:00"}'

I do not work very well with this format

$ curl -X GET '127.0.0.1:5984/misc/_design/foo/_view/view1?startkey="2012-02-02"'

Because the document appears as a result.

Thank,

Eric J.

+3
source share
1 answer

I suggest you use your first format, or perhaps the standard JSON2 format , which is most convenient for JavaScript. This is what most people do, and it works well with your example:

$ curl '127.0.0.1:5984/misc/_design/foo/_view/view1?startkey="2012-02-02"'

To check your data, use the check function .

+2
source

All Articles