2016-10-18 5 views
1

これで、Parse Serverのポインタに関する問題が発生しました。 私は、ポインタを持つ2つの他のテーブルを接続するテーブルを持っています。パースのJavascript:予想されるエラー111ポインタですが、[オブジェクトオブジェクト]があります

例:

var table1id //ID of the first table 
var table2id //ID of the second Table 
var Example = Parse.Object.extend('example_table'); 

function add_newExample(table1id, table2id) { 
    var example = new Example(); 
    example.set('table1_id', table1id); 
    example.set('table2_id', table2id); 
    example.save(null, { 
     success: function() { 
      console.log('New object created'); 
     }, 
     error: function (error) { 
      console.log('Failed to create new object'); 
     } 
    }) 
} 

エラー:私は見

code: 111 error: "schema mismatch for example_table.table1id; expected Pointer but got [object Object]"

答えて

1

上記のコードから、table1_id table2_idのフィールドが想定されているかどうか、または設定した内容がわからないことがあります。

ダッシュボードでexample_tableを見ると、その列はどのようなタイプですか?

しかし、私はそれらが(あなたが得ているエラーに基づいて)他のテーブルの行へのポインタである必要があると仮定します。その場合、以下があなたのために働くはずです。

const Example = Parse.Object.extend('example_table'); 

const Table1 = Parse.Object.extend('table1'); 
const table1Ptr = new Table1().set('objectId', '1'); 

const Table2 = Parse.Object.extend('table2'); 
const table2Ptr = new Table2().set('objectId', '6'); 

const addNewExample = function addNewExample(table1Ptr, table2Ptr) { 
    // return the promise that results from the save 
    return new Example() // just chaining everything to be terse... 
    .set('table1_id', table1Ptr) 
    .set('table2_id', table2Ptr) 
    .save(null, { useMasterKey: true }) // may not be necessary, depending 
    // 
    // don't use these old style handlers, use promise syntax 
    // which I substitute for the following below. 
    // success: function() { 
    // console.log('New object created'); 
    // }, 
    // error: function (error) { 
    // console.log('Failed to create new object'); 
    // } 
    .then(
     // fancy fat arrow notation for functions like the cool kids... 
     o => console.log('new object: ' + o.id + ' created'), 
     e => console.error('uh oh: ' + e.message) 
    ); 
}; 

addNewExample(table1Ptr, table2Ptr); 
0

まず問題は、タイプミスを持っています。 var example = new Exmaple(); var example = newでなければなりません。

+0

Ohh dammetですが、これは問題ではありません。私がここに貼り付けると起こります。 –

関連する問題