【问题标题】:Can't retrieve more then 50 records from Azure MobileServiceClient (Node.js)无法从 Azure MobileServiceClient (Node.js) 检索超过 50 条记录
【发布时间】:2016-07-18 16:09:13
【问题描述】:

所以我正在构建一个基于 angularjs 的 Apache Cordova 应用程序 (Android),并使用 WindowsAzure MobileServiceClient 库从我在 SQL 数据库中创建的 Easy Table 中检索数据。

这行得通!直到我想检索超过 50 条记录。 所以我将 .take(100) 添加到我的表格读取中。还有50条记录.. 然后我想,可能take函数根本不起作用,所以我将数量改为5,我只得到了5条记录。所以 take 函数有点工作,但不超过 50 条记录。

既然是node.js后端,如何增加pagesize?

这是我当前的代码:

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);
}

【问题讨论】:

    标签: angularjs node.js apache cordova azure


    【解决方案1】:

    根据node.js中Mobile Apps的表操作源码,read operation最终接收到context.query,这是一个queryjs对象,其中包含一个take()函数,可以限制返回的项目数到指定的数字。

    另外,take() 函数包含在移动应用服务器 sdk 中,因此它不适用于您的客户端代码。

    您可以对 Easy Tables 脚本进行一些修改,例如

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-21
      • 1970-01-01
      • 2012-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多