-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added blank POST endpoint to pull a blank object for binding to forms for CREATE operations #3
base: master
Are you sure you want to change the base?
Conversation
… fields or default value if provided
…nerated blank object
…e skipped in the blank
Thanks for submitting this pull request, it's a really interesting idea and I like that you can get a fresh object without actually creating the resource. I hesitate to accept the request, since PROPFIND as specified in RFC 2518 is used for retrieving specific property values on a resource. Here is a stack overflow asking for advice on what you are trying to do. One answer suggests adding a /template endpoint (i.e. /users/template), while another suggests a POST to /users and getting back the newly created object. I'm partial to the second approach. Perhaps we could accept a POST to /users without a body, detect there were no properties submitted, and return the empty object? Up for suggestions. |
Ah! Thanks for the stack overflow reference- just what I needed. Will On Tuesday, 13 October 2015, Dave Artz [email protected] wrote:
|
Ok - done. By the way when I did a fresh clone to test it I encountered issues with the version of mongoose being referenced (^3.8.19): Got a big "This is an UNSTABLE release of Mongoose." warning and then an exception in the mongoose code: "TypeError: Cannot read property 'length' of undefined". I fixed it by changing the package.json devDependency to "mongoose": "^4.1.11" This is a separate issue from the pull request though, so didn't include it. |
I'm about to release a package that lets you generate Knockout viewmodels automatically against the meanify SCRUD endpoints. Something missing was a way to get a blank model object for the purpose of binding against a form used for the CREATE operation.
This PROPFIND endpoint returns an object that has null for all fields in the model, except for any that have default values. Default values that are functions will be evaluated each time.
e.g. PROPFIND /api/posts
returns { title:null,author:null ... }
PROPFIND is an 'extension method' under the http spec (https://tools.ietf.org/html/rfc2616) and is one of the routing methods supported by express (http://expressjs.com/guide/routing.html). Happy to change to a different endpoint if you think it makes more sense (e.g. GET /api/posts/__blank or something?)