.has('orders', function(factory) { if (factory.get('delivery')) { return o.array(o.ref(orderFactory)) .has('customer.name', factory.get('location.name')) .length(1); } else { return o.array(o.ref(orderFactory)) .has('number', function(factory) { return factory.index + 1; }); } });
}) .has('serviceTime', 300) .has('orders', function(factory) { if (factory.get('delivery')) { return o.array(o.ref(orderFactory)) .has('customer.name', factory.get('location.name')) .length(1); } else { return o.array(o.ref(orderFactory)) .has('number', function(factory) { return factory.index + 1; }); } }); var routeFactory = mongooseFactory .type(Route) .has('stops', o.array(o.ref(stopFactory)).length(10)) .has('foodhub', function(factory) { return factory.option('foodhub'); }); routeFactory .has('stops[length]', 3) .has('stops[0].startAt', moment('2014-06-01 12:30').toDate()) .has('stops[*].viamente.driver', '*****@*****.**') .populate('stops.orders.fulfillments') .create(function(route) { return console.log(route); });