Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added ignore-capability to mongoose-friendly

  • Loading branch information...
commit a340351354010efc7423fc96180c1506688bc678 1 parent c517877
@hkjels authored
View
1  Taskpool.md
@@ -2,6 +2,7 @@
# Taskpool
+* TODO @henrik #pri[1] Make app.crud work with multiple models at a time
* TODO @henrik Create a #test for all mongoose-types and validation
* TODO @henrik Add messages through express-messages
* TODO @henrik Add match-patterns to the form-elements on the client-side
View
2  examples/user/app.js
@@ -69,7 +69,7 @@ app.get('/', function (req, res) { res.render('explain') })
* Start listening
*/
-app.listen(8080, function(){
+app.listen(3000, function(){
console.log('Crud example is listening on port %d', app.address().port)
})
View
3  examples/user/models/Users.js
@@ -14,7 +14,8 @@ var mongoose = require('mongoose')
*/
var Users = new Schema({
- 'name': {
+ 'added': {type: Date, 'default': Date.now, ignore: true}
+ , 'name': {
'first': {type: String, required: true}
, 'last': String
}
View
15 examples/user/views/form.jade
@@ -13,13 +13,14 @@ form(action='/api/'+form.model+'/'+(form.id || ''), method='post')
fieldset
each field in form.fields
- .inline-block
- if field.type !== 'hidden'
- label(for='[name='+field.shortName+']', class=field.required ? 'required' : '')= field.shortName
- if field.type === 'textarea'
- textarea(name=field.name, required=field.required, maxlength=field.max)= field.value || null
- else
- input(type=field.type, name=field.name, required=field.required, maxlength=field.max, value=field.value)
+ if !field.ignore
+ .inline-block
+ if field.type !== 'hidden'
+ label(for='[name='+field.shortName+']', class=field.required ? 'required' : '')= field.shortName
+ if field.type === 'textarea'
+ textarea(name=field.name, required=field.required, maxlength=field.max)= field.value || null
+ else
+ input(type=field.type, name=field.name, required=field.required, maxlength=field.max, value=field.value)
fieldset
input(type='submit', value=form.filled ? 'update' : 'add')
View
2  lib/mongoose-friendly.js
@@ -103,6 +103,8 @@ var friendly = module.exports = function friendly (model) {
if (typeof Schema[field]['options']['max'] !== 'undefined') {
fields[field]['max'] = Schema[field]['options']['max']
}
+
+ fields[field]['ignore'] = Schema[field].options.ignore
}
form['fields'] = fields
Please sign in to comment.
Something went wrong with that request. Please try again.