2

Windows Azure Node.js SDKを使用して継続トークンを取得する方法を知りたいですか?たとえば、SDKを使用して、テーブルからデータを取得するためにこれを実行します。

var tableService = azure.createTableService();

tableService.getTable('UsersUserFacebookActions', function (error) {
    if (error === null) {
        var query = azure.TableQuery
            .select()
            .from('UsersUserFacebookActions')
            .where('PartitionKey eq ?', userID)
            .and('Kind eq ?', 'User')
            .and('Deleted eq ?', 'false');

        tableService.queryEntities(query, function (error, userEntities) {
            if (error === null && userEntities.length > 0) {
                // check to see if access token needs extending
                extendAccessToken(userEntities[0], function (user) {
                    callback({
                        PartitionKey: user.PartitionKey,
                        RowKey: user.RowKey,
                        Kind: user.Kind,
                        EmailAddress: user.EmailAddress,
                        AccessToken: user.AccessToken,
                        TokenExpiration: user.TokenExpiration,
                        JoinDate: user.JoinDate,
                        ChannelCount: user.ChannelCount,
                        FollowCount: user.FollowCount,
                        ChannelCountString: accounting.formatNumber(user.ChannelCount),
                        FollowCountString: accounting.formatNumber(user.FollowCount),
                        Deleted: user.Deleted,
                        DeleteDate: user.DeleteDate
                    }); 
                });
            }
            else callback();
        });
    }
    else callback();
});

しかし、私はこのサイトを含む例とドキュメントを探しました:

https://www.windowsazure.com/en-us/develop/nodejs/

しかし、継続トークンについて言及しているものは何もありません。

どんな助けやアドバイスもいただければ幸いです。

4

3 に答える 3

3

ソース (行 481) によると、継続トークンが存在する場合、「queryEntitiesResultContinuation」プロパティが結果に追加されます。

https://github.com/WindowsAzure/azure-sdk-for-node/blob/master/lib/services/table/tableservice.js

これには、コールバックを受け取る「getNextPage」という関数があります。

https://github.com/WindowsAzure/azure-sdk-for-node/blob/master/lib/services/table/models/queryentitiesresultcontinuation.js

おそらく、クエリの結果を処理する別の関数を作成する必要があります。この関数はエンティティを繰り返し処理し、「queryEntitiesResultContinuation」が設定されているかどうかを確認します。その場合は、関数を呼び出して、新しい関数をコールバックとして渡します。

実際に試したことはなく、コード サンプルも見つかりません。

アップデート

ノードで継続トークンを処理するためのコード サンプルを次に示します。

var tableService = require("azure").createTableService();

function queryWithContinuation(query, cb) {
    tableService.queryEntities(query, function(error, entities, continuationToken){
        if (continuationToken.nextPartitionKey) { 
            nextPage(entities, continuationToken, cb);
        } else {
            cb(entities);                    
        }
    });
}

// used to recursively retrieve the results
function nextPage(entities, continuationToken, cb){
    continuationToken.getNextPage(function(error, results, newContinuationToken){
        entities = entities.concat(results);
        if (newContinuationToken.nextPartitionKey){
            nextPage(entities, newContinuationToken, cb);
        } else {
            cb(entities);
        }
    });
}

// example usage
var query = azure.TableQuery.select().from('really-big-table');
queryWithContinuation(query, function(results){
    console.log(results);
});
于 2012-05-18T09:01:20.113 に答える
0

私はnode.jsに慣れていません。ただし、クライアント ライブラリが継続トークンをサポートしていない場合でも、手動で HTTP リクエストを発行できます。http://nodejs.org/api/https.html#https_https_get_options_callbackのドキュメントには、node.js から HTTP 要求を発行する方法が記載されています。また、http://msdn.microsoft.com/en-us/library/ のドキュメントには、 windowsazure/dd135718は、HTTP 要求を使用して継続トークンを使用する方法を示しています。それらを組み合わせると、シナリオが機能します。Richard は、Windows Azure node.js クライアント ライブラリの使用方法に関する詳細情報を提供する場合があります。これにより、プロセスが簡単になる可能性があります。

よろしくお願いします、

明徐。

于 2012-05-21T07:27:05.923 に答える