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!
Asked
Active
Viewed 305 times
1
-
@JoseLora Hopefully my answer solves the mystery of what my question was. Thanks! – nolanxiii Oct 21 '21 at 18:57
1 Answers
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