Adam
Adam

Reputation: 1242

Sails js rest api date range

I have a sails api with the created date formatted like

"createdAt": "2018-11-01T11:49:53.700Z",

i can get the contains filtering on a field working e.g

api2/items?status=IN_PROGRESS

but can't get the date range working, have tried the following

api2/items?createdAt={'>=":2018-11-01T11:49:53.700Z, '<=":2018-11-01T11:49:53.700Z}

/api2/items?where={createdAt: { '>=': 2018-11-01T11:49:53.700Z, '<=': 2018-11-01T11:49:53.700Z }}

any ideas?

Upvotes: 1

Views: 286

Answers (1)

streleck
streleck

Reputation: 459

I don't believe waterline supports this type of query on a datetime field. I would urge you to instead store these as a number (the unix time), which you will more easily be able to do such queries. When you want to format these items for display, you can use moment.js to help out.

Upvotes: 1

Related Questions