Created
February 22, 2012 00:53
-
-
Save dreamr/1880284 to your computer and use it in GitHub Desktop.
Why is it that I end up with the ObjectId instead of unit.race -> Race() ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="clearfix"> | |
<%- form.label("race") %> | |
<div class="input"> | |
<%- form.input( 'race' ) %> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, ObjectId = Schema.ObjectId; | |
var Race = describe('Race', function () { | |
property('name', String); | |
}); | |
var Unit = describe('Unit', function () { | |
property('name', String); | |
property('race', { type: ObjectId, ref: 'Race'}); | |
property('type', String); | |
property('at1', Number); | |
property('at2', Number); | |
property('at3', Number); | |
property('dt1', Number); | |
property('dt2', Number); | |
property('dt3', Number); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unit.attackTypes = function () { | |
return ['at1', 'at2', 'at3']; | |
}; | |
Unit.defenseTypes = function () { | |
return ['dt1', 'dt2', 'dt3']; | |
}; | |
Unit.types = function () { | |
return ['land', 'water', 'air', 'space']; | |
}; | |
// Unit.races = function () { | |
// return ['terran', 'alien']; | |
// }; | |
Unit.validatesPresenceOf('name') | |
Unit.validatesLengthOf('name', {min: 5}) | |
Unit.validatesPresenceOf('at1') | |
Unit.validatesPresenceOf('at2') | |
Unit.validatesPresenceOf('at3') | |
Unit.validatesPresenceOf('dt1') | |
Unit.validatesPresenceOf('dt2') | |
Unit.validatesPresenceOf('dt3') | |
Unit.validatesPresenceOf('raceId') | |
Unit.validatesPresenceOf('type') | |
Unit.validatesInclusionOf('type', {in: Unit.types()}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment