vendredi 29 août 2014

how to stop rethinkdb converting object to array?


Vote count:

0




I'm very confused here. I'm passing an object called ScheduleAdd, and using insertAt to enter that object into an array called 'schedules' that exists in each document in the table 'teachers'. Rethink is throwing the error "Inserted value must be an OBJECT (got ARRAY)". It shows me an array that consists of my passed object with square brackets around it.


Code:



var scheduleAdd = {};
scheduleAdd.schedule = name;
scheduleAdd.visible = 'yes';
console.log(scheduleAdd);
r.db('test').table('teachers').update(function(teacher) {return teacher('schedules').insertAt(0,scheduleAdd)}).run(connection, function(err, result) {
if (err) throw err;
;
console.log('updated teacher schedules');
console.log(result);
});
});


As an example, I might pass the object:



{ schedule: 'weekend', visible: 'yes' }


The console.log confirms that the object is well formed. However Rethink will then throw the error:



'Inserted value must be an OBJECT (got ARRAY):\n["{\\n \\"schedule\\": \\"weekend\\",\\n \\"visible\\": \\"yes\\"\\n}"]',


Any idea why my object is being converted into an array, and how I can stop it from happening? Thanks!



asked 1 min ago







how to stop rethinkdb converting object to array?

Aucun commentaire:

Enregistrer un commentaire