You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When referencing model(s), an object might be designed to only hold the primaryKey(s) of the referenced model(s). For example, Mirage when relating the models blogPost and comments,...
import{createServer,Model,hasMany}from"miragejs"createServer({models: {blogPost: Model.extend({comments: hasMany(),// relation to `comments` model}),comment: Model,},})
...creates several helpful keys for the association. In addition, if I wanted the association to be named differently, I could create the association like so: hasMany("different name for association here").
blogPost.commentIds// [1, 2, 3]blogPost.commentIds=[2,3]// updates the relationshipblogPost.comments// array of related commentsblogPost.comments=[comment1,comment2]// updates the relationshipblogPost.newComment(attrs)// new unsaved commentblogPost.createComment(attrs)// new saved comment (comment.blogPostId is set)
The text was updated successfully, but these errors were encountered:
When referencing model(s), an object might be designed to only hold the
primaryKey(s)
of the referenced model(s). For example, Mirage when relating the modelsblogPost
andcomments
,......creates several helpful keys for the association. In addition, if I wanted the association to be named differently, I could create the association like so:
hasMany("different name for association here")
.The text was updated successfully, but these errors were encountered: