Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added ignore-capability to mongoose-friendly

  • Loading branch information...
commit a340351354010efc7423fc96180c1506688bc678 1 parent c517877
Henrik Kjelsberg authored
1  Taskpool.md
Source Rendered
@@ -2,6 +2,7 @@
2 2 # Taskpool
3 3
4 4
  5 +* TODO @henrik #pri[1] Make app.crud work with multiple models at a time
5 6 * TODO @henrik Create a #test for all mongoose-types and validation
6 7 * TODO @henrik Add messages through express-messages
7 8 * TODO @henrik Add match-patterns to the form-elements on the client-side
2  examples/user/app.js
@@ -69,7 +69,7 @@ app.get('/', function (req, res) { res.render('explain') })
69 69 * Start listening
70 70 */
71 71
72   -app.listen(8080, function(){
  72 +app.listen(3000, function(){
73 73 console.log('Crud example is listening on port %d', app.address().port)
74 74 })
75 75
3  examples/user/models/Users.js
@@ -14,7 +14,8 @@ var mongoose = require('mongoose')
14 14 */
15 15
16 16 var Users = new Schema({
17   - 'name': {
  17 + 'added': {type: Date, 'default': Date.now, ignore: true}
  18 + , 'name': {
18 19 'first': {type: String, required: true}
19 20 , 'last': String
20 21 }
15 examples/user/views/form.jade
@@ -13,13 +13,14 @@ form(action='/api/'+form.model+'/'+(form.id || ''), method='post')
13 13
14 14 fieldset
15 15 each field in form.fields
16   - .inline-block
17   - if field.type !== 'hidden'
18   - label(for='[name='+field.shortName+']', class=field.required ? 'required' : '')= field.shortName
19   - if field.type === 'textarea'
20   - textarea(name=field.name, required=field.required, maxlength=field.max)= field.value || null
21   - else
22   - input(type=field.type, name=field.name, required=field.required, maxlength=field.max, value=field.value)
  16 + if !field.ignore
  17 + .inline-block
  18 + if field.type !== 'hidden'
  19 + label(for='[name='+field.shortName+']', class=field.required ? 'required' : '')= field.shortName
  20 + if field.type === 'textarea'
  21 + textarea(name=field.name, required=field.required, maxlength=field.max)= field.value || null
  22 + else
  23 + input(type=field.type, name=field.name, required=field.required, maxlength=field.max, value=field.value)
23 24
24 25 fieldset
25 26 input(type='submit', value=form.filled ? 'update' : 'add')
2  lib/mongoose-friendly.js
@@ -103,6 +103,8 @@ var friendly = module.exports = function friendly (model) {
103 103 if (typeof Schema[field]['options']['max'] !== 'undefined') {
104 104 fields[field]['max'] = Schema[field]['options']['max']
105 105 }
  106 +
  107 + fields[field]['ignore'] = Schema[field].options.ignore
106 108 }
107 109
108 110 form['fields'] = fields

0 comments on commit a340351

Please sign in to comment.
Something went wrong with that request. Please try again.