1

I am wondering how I could change the default, generated id column for a mirage db from 'id' to something like 'userId' as my front end expects. Thanks!

nolanxiii
  • 41
  • 4

1 Answers1

3

Figured it out, this can be done by extending your serializer and using the keyForAttribute function. It will look something like:

createServer({
  serializers:{
    user: RestSerializer.extend({
      keyForAttribute(key){
        return key === 'id' ? 'userId' : key
      },
    })
  },
  //models{...}
  // rest of createServer...
)}
nolanxiii
  • 41
  • 4