Permalink
Browse files

added field level function interpolation

  • Loading branch information...
1 parent 92b5410 commit b26e596a750273c314de0c58bd7774db7a06af9e @funkytek funkytek committed Sep 17, 2013
Showing with 7 additions and 5 deletions.
  1. +6 −4 lib/main.coffee
  2. +1 −1 package.json
View
@@ -13,7 +13,7 @@ module.exports =
clear: (cb) ->
@runPre "clear", [], (err) =>
return cb err if err?
- async.parallel (m.remove.bind m for _, m of @db.models), (err) =>
+ async.parallel (m.remove.bind m for __, m of @db.models), (err) =>
@runPost "clear", [], cb
create: (cb) ->
@@ -24,7 +24,9 @@ module.exports =
data = @models[name]
@collection[name] = []
data = data() if data instanceof Function
- async.each data, (model, next) =>
+ async.eachSeries data, (model, next) =>
+ for k, v of model
+ model[k] = v() if v instanceof Function
type.create model, (err, res) =>
if err? then console.log "err: #{err}"
@collection[name].push res
@@ -43,14 +45,14 @@ module.exports =
ref: (model, query) ->
if query?
- return _.find(@collection[model], query)._id
+ return (_.find(@collection[model], query))._id
else
# just ObjectId
return @rand(model)._id
embed: (model, query) ->
if query?
- return _.find @collection[model], query
+ return (_.find @collection[model], query)
else
# randomize
return @rand(model)
View
@@ -1,7 +1,7 @@
{
"name": "seedling",
"description": "seed data utility for mongoose",
- "version": "0.0.3",
+ "version": "0.0.5",
"homepage": "http://github.com/wearefractal/seedling",
"repository": "git://github.com/wearefractal/seedling.git",
"author": "Fractal <contact@wearefractal.com> (http://wearefractal.com/)",

0 comments on commit b26e596

Please sign in to comment.