ember.js - Ember Data plural serializer -
i have product
model, , /products/
route - ember data sends request host/api/v1/product
instead of host/api/v1/products
- why this?
also, how can use plural end point individual product fetch? i.e: host/api/v1/product/1
check buildurl method
by default, pluralizes type's name (for example, 'post' becomes 'posts' , 'person' becomes 'people'). override pluralization see [pathfortype](#method_pathfortype).
and there list of sub-methods ( https://github.com/emberjs/data/blob/v2.6.1/addon/-private/adapters/build-url-mixin.js#l54 )
switch (requesttype) { case 'findrecord': return this.urlforfindrecord(id, modelname, snapshot); case 'findall': return this.urlforfindall(modelname, snapshot); case 'query': return this.urlforquery(query, modelname); case 'queryrecord': return this.urlforqueryrecord(query, modelname); case 'findmany': return this.urlforfindmany(id, modelname, snapshot); case 'findhasmany': return this.urlforfindhasmany(id, modelname, snapshot); case 'findbelongsto': return this.urlforfindbelongsto(id, modelname, snapshot); case 'createrecord': return this.urlforcreaterecord(modelname, snapshot); case 'updaterecord': return this.urlforupdaterecord(id, modelname, snapshot); case 'deleterecord': return this.urlfordeleterecord(id, modelname, snapshot); default: return this._buildurl(modelname, id); }
so can redefine purposes
Comments
Post a Comment