Ross Rawlins
Ross Rawlins

Reputation: 667

Azure mobile apps client query offline data

I am trying to query my local table to get specific set of data and I keep getting a syntax error. What is the correct way to use the where clause. I am looking at this resource:

https://azure.github.io/azure-mobile-apps-js-client/MobileServiceSqliteStore.html#read

And I not able to get my code to function. I am able to get the tables full set of data with just a plain read.

this.azureStore = new WindowsAzure.MobileServiceSqliteStore('db_offline');

var queryString = "EventId eq " + 
        eventId  + " and Start gt datetime('" + 
        moment.utc(dayDate).startOf('day').format('YYYY-MM-DDTHH:mm:00') + "Z') and Start lt datetime('" + 
        moment.utc(dayDate).endOf('day').format('YYYY-MM-DDTHH:mm:00') + "Z')";
        this.azureStore.read(new WindowsAzure.Query('Timeslots').where(queryString));

Upvotes: 0

Views: 61

Answers (1)

Aaron Chen
Aaron Chen

Reputation: 9950

You'll need to format the date value as shown below:

Start gt datetime'2017-05-30T09:13:28.000Z'

Then the code will look something like this:

this.azureStore = new WindowsAzure.MobileServiceSqliteStore('db_offline');

var queryString = "EventId eq " 
        + eventId  + " and Start gt datetime'" 
        + moment.utc(dayDate).startOf('day').format('YYYY-MM-DDTHH:mm:ss:000') 
        + "Z' and Start lt datetime'"
        + moment.utc(dayDate).endOf('day').format('YYYY-MM-DDTHH:mm:ss:000') + "Z'";
        this.azureStore.read(new WindowsAzure.Query('Timeslots').where(queryString));

Upvotes: 1

Related Questions