Hey guys, i’m trying to import a bunch of scraped data for my app and i’m currently having problems regarding data duplication.
I figure it was simply a matter querying to the firebase database during the import before creating a new record.
// this function is called elsewhere from inside a forEach loop
_createShop(data) {
// is something wrong with the query perhaps?
return this.store.query('shop', { orderBy: 'name', equalTo: data.shopName }).then((shop) => {
if (shop.get('length')) {
// if exists, just return the object
return shop.get('firstObject');
} else {
// or continue creating a new record
return this.store.createRecord('shop', {
name: data.shopName,
// some other stuff
}).save();
}
});
}
But i’m still getting multiple records with the same name. Any ideas?