The id xxx has already been used with another record of type
See original GitHub issueI’m attempting to check if a user
model exists before creating it but I’m getting: Error: Assertion Failed: The id xxx has already been used with another record of type app@model:user.
This is my code:
// authData comes from Firebase
checkUser: function() {
var savedUser = this.get('store').find('user', this.get('authData.uid'));
savedUser.then(function(savedUser) {
self.set('user', savedUser);
}, function(user) {
self.createUser();
});
},
createUser: function(user) {
var self = this;
// it fails here!
var newUser = this.get('store').createRecord('user', {
id: this.get('authData.uid'),
created: new Date().getTime()
}).save().then(function(newUser) {
Ember.debug('created a new user');
self.set('user', newUser);
}, function() {
Ember.debug('could not save user');
self.set('user', null);
});
}
If I leave the check out, the code runs but overwrites the user model on every login, which I don’t believe is desirable. I’m using Ember 1.8.0-beta.4 and Emberfire 1.2.7.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
The id xxx has already been used with another record of type
I'm attempting to check if a user model exists before creating it but I'm getting: Error: Assertion Failed: The id xxx has already...
Read more >Troubleshooting submissions - Crossref
Solution 1: Change the journal level DOI in your submission to match the previously registered journal level DOI and resubmit.
Read more >Working with Authority Records - Ex Libris Knowledge Center
To create a local authority record: Open the MD Editor. Select File > New and select from the list of local vocabularies that...
Read more >Supported DNS record types - Amazon Route 53
Describes the DNS record types that are supported by Route 53. ... You can't create a CAA record and a CNAME record that...
Read more >Claim Denial Codes List - Utah Medicaid
Procedure is sex specific. Client is the wrong sex for procedure. Verify ID#. 3. The procedure code is inconsistent with the patient's gender....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This does not appear to be a bug in emberfire, rather that ember-data creates a temporary record in its store when you do
find
(regardless of whether it is found or not):here’s my workaround:
Hey @20v100, there are two parts: checking if a record exists and if not, create it. So I ended up replacing the check with native Firebase code instead of using the Emberfire adapter. It’s a temporary solution that works for me so far .