qorsmond
qorsmond

Reputation: 1246

date-time equality in breezejs

I am stuck with date-time equality in breezejs.

What I want to do is query data and return only the latest records that changed since my last sync.

...
query = query.where('ModifiedDateTime', '>=', lastSyncDate);

The ModifiedDateTime is a DateTime type on the dB side, and the lastSyncDate is the datetime of last sync from new Date(Date.now())

This works for the day but not for the time, what I wanted to do is call the getTime() function to get an integer to compare like described here: Beware equality tests but I can't figure out how to do it in the where clause?

Something like

query = query.where(ModifiedDateTime.getTime(), '>=', lastSyncDate.getTime());

But obviously this is not possible, is there another way to do it?

Upvotes: 1

Views: 129

Answers (1)

Ward
Ward

Reputation: 17863

Browser DateTime is unlikely to be the same as server DateTime in the real world. I think you need a way to get the server sync DateTime from the server and use that in your request. A recommendation on how to proceed depends much on how you define lastSyncDateTime and perhaps your willingness to supplement the client/server protocol to include sync DateTime in the server response AND dig that out on the client so you can use it in a query. The tools are there but there is nothing native in Breeze to support this.

You might have a good feature request here for out-of-the-box breeze Web API protocol enhancement. You might suggest that we extend that protocol to include the server DateTime in the response (e.g. in a custom header) AND make that available to the breeze application developer as one of the properties of the query (and save) result.

But getting ahead of myself. First step is to explain what your need for this is and how you use it.

Upvotes: 1

Related Questions