Lars Stolwijk
Lars Stolwijk

Reputation: 56

Can't retrieve more then 50 records from Azure MobileServiceClient (Node.js)

So I'm building an Apache Cordova app (Android), angularjs based, and using the WindowsAzure MobileServiceClient library to retrieve data from my Easy Table's, created in a SQL Database.

This works! Until I'd like to retrieve more then 50 records. So I added the .take(100) to my table-read. Still 50 records.. Then I thought, maybe the take function doesn't work at all, so I changed the amount to 5, and I only got 5 records. So the take function is somewhat working, but not above 50 records.

Since it's a node.js backend, how do I increase the pagesize?

Here's my current code:

msc.tables.pokemonType = null;
msc.tables.pokemon = null;

msc.init = function () {
    console.log('MobileServiceClient initializing...');

    var mobileServiceClient = new WindowsAzure.MobileServiceClient("https://blablablabla");

    msc.tables.pokemonType = mobileServiceClient.getTable('PokemonType');
    msc.tables.pokemon = mobileServiceClient.getTable('Pokemon');

    console.log('MobileServiceClient initialized!');
}


msc.getAllPokemonTypes = function() {
    console.log('getAllPokemonTypes - called');
    return msc.tables.pokemonType.read().then(function (pokemonTypes) {
        console.log('getAllPokemonTypes - done');
        return pokemonTypes;
    }, msc.handleError);
}

msc.getAllPokemons = function () {
    console.log('getAllPokemons - called');
    return msc.tables.pokemon.take(100).read().then(function (pokemons) {
        console.log('getAllPokemons - done');
        return pokemons;
    }, msc.handleError);
}

Upvotes: 0

Views: 196

Answers (1)

Gary Liu
Gary Liu

Reputation: 13918

According the source code of table operations of Mobile Apps in node.js, the read operation ultimately receives context.query which is a queryjs object, which contains a take() function which can limit the number of items returned to the specified number.

Additionally, the take() function is contained in the mobile app server sdk, so it doesn't work on your client end code.

You can do some modification on your Easy Tables scripts, E.G.

table.read(function (context) {
    context.query.take(100);
    return context.execute();
});

Upvotes: 1

Related Questions