MirageJS
Last updated:
AQW
Database level
Can access with server.db
this.get("/posts", (schema) => {
return schema.db.posts;
});
afterCreate hook
In Factory, model will be created first. Then run all afterCreate
hooks in order. Then any trait
will be run as specified order.
association() helper
post: Factory.extend({
user: association(),
}),
replaces this code:
afterCreate(post, server) {
if (!post.user) {
post.update({
user: server("user"),
})
}
},
Only use for belongsTo
and not belongsTo polymorphic