mikkopaderes / ember-cloud-firestore-adapter

Unofficial Ember Data Adapter and Serializer for Cloud Firestore
MIT License
69 stars 17 forks source link

Creating records with custom id #255

Closed knownasilya closed 2 years ago

knownasilya commented 2 years ago

Is there a way to do this? If not, this is a request for that 😄

charlesfries commented 2 years ago

You should be able to either pass in id to createRecord() or override generateIdForRecord if you have a specific format you want to use:

// app/adapters/application.js

generateIdForRecord(store, type): string {
  const id = super.generateIdForRecord(store, type);
  return `${type.substring(0, 3)}_${id}`;
}
knownasilya commented 2 years ago

I tried passing id, and that didn't create the record. Maybe there was some other issue. Will try again later.

knownasilya commented 2 years ago

It does work, 🤷🏼 seems like I had something else going on before.