async function saveNewCrime(me,crime,date,location,description,city_of_crime) {
//Create your Parse Object
const crimeReported = new Parse.Object('crime_report');
//Define its attributes
// crimeReported.set('objectId', id);
crimeReported.set('crime_type', crime);
crimeReported.set('date', date);
crimeReported.set('user_id', "jHfUJtvg2y");
crimeReported.set('description', description);
crimeReported.set('location',location);
crimeReported.set('city',city_of_crime);
try {
//Save the Object
const result = await crimeReported.save();
console.log('New object created with objectId: ' result.id);
} catch (error) {
console.log('Failed to create new object: ' error.message);
}
}
I am trying to upload data to back4app and in a crime reported collections every time I try to run the code I get an error saying
Failed to create new object: schema mismatch for crime_report.user_id; expected Pointer<_User> but got String
from what I understand is that im passing a string where it expects a pointer does anyone know how I can approach getting a pointer ?
CodePudding user response:
Try the following code:
(async function saveNewCrime(me,crime,date,location,description,city_of_crime) {
//Create your Parse Object
const crimeReported = new Parse.Object('crime_report');
//Define its attributes
// crimeReported.set('objectId', id);
crimeReported.set('crime_type', crime);
crimeReported.set('date', date);
crimeReported.set('user_id', new Parse.User({'objectId': 'jHfUJtvg2y'}));
crimeReported.set('description', description);
crimeReported.set('location',location);
crimeReported.set('city',city_of_crime);
try {
//Save the Object
const result = await crimeReported.save();
console.log('New object created with objectId: ' result.id);
} catch (error) {
console.log('Failed to create new object: ' error.message);
}
})();