2

So i got some Problems with Pointer in Parse Server. I got a Table, that connect two other Tables with Pointers.

Example:

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

Error:

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

2 Answers 2

2

It's not clear from the code above what the fields for table1_id table2_id are supposed to be or what you have them set to.

If you look at example_table in the dashboard, what type do the columns say they are?

But I'll assume that they should be pointer to rows in other tables (based on the error you're getting), in which case, the below should work for you.

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);
Sign up to request clarification or add additional context in comments.

Comments

-1

First issue i see is you have a typo. var example = new Exmaple(); should be var example = new Example();

1 Comment

Ohh dammet, but this isn't the Problem. It happen when i paste it in here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.