0

新しいデータを Angular の DataStore に保存するときに、_id を指定したくありません。システムによって自動的に割り当てられます。ネットワークトレースを見ると、応答で_idがアプリケーションに返されます-https://baas.kinvey.com/appdata/appxxx/activities/54ac3d8671e2d7933b0116b4-しかし、とにかくAngularでそれを見つけることはわかりませんその _id を取得して既存のリストに追加したり、他の処理を実行したりする方法に関するドキュメント。

    var promise = $kinvey.DataStore.save('activities', {
                text : $scope.newActivity.text ,
                duedate : '2015-01-01'
            });
         promise.then(
             function () {
                 $scope.newActivity.text = '';
             },
             function (error) {
                 //Kinvey insert finished with error
                 alert("Error insert: " + JSON.stringify(error));
             });
4

1 に答える 1

0

Kinvey will actually return the object to you in the promise, and you can just grab the _id off the returned object.

promise.then(function(data) {
    // Here's where you get your _id
    $scope.newActivity.text = data._id;
}, function(err) {
    console.error(err);
});
于 2015-01-14T16:59:10.473 に答える