Sorting data using Order By created or last modified time

query
n1ql
index

#1

How to sort data by created or last modified time.Can anyone give me full example of it? thanks.


Adding new object to existing document using N1QL
#2

If you store date as ISO-8601 format you can use any N1QL functions.
https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/datefun.html

INSERT INTO default VALUES ("k01", {"created":"2015-12-19T05:05:43.897-08:00"});
INSERT INTO default VALUES ("k01", {"created":"2018-12-19T05:05:43.897-08:00"});
INSERT INTO default VALUES ("k01", {"created":"2014-12-19T05:05:43.897-08:00"});

SELECT created FROM default WHERE created >"2010-12-19"
ORDER BY created DESC;

Adding new object to existing document using N1QL