Comparing version 0.5.6 to 0.5.7
@@ -0,1 +1,7 @@ | ||
## 0.5.7 (2015-08-06) | ||
Bugfixes: | ||
- Fixed issue where `schema()` wasn't canonicalizing schema definitions. | ||
- Updated README to show an example of using `schema()`. | ||
## 0.5.6 (2015-07-20) | ||
@@ -2,0 +8,0 @@ |
@@ -103,2 +103,5 @@ "use strict"; | ||
if (!extension) return; | ||
_.keys(extension).forEach(function(k) { | ||
extension[k] = normalizeType(extension[k]); | ||
}); | ||
_.assign(this._schema, extension); | ||
@@ -105,0 +108,0 @@ } |
{ | ||
"name": "camo", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"description": "A class-based ES6 ODM for Mongo-like databases.", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -105,4 +105,22 @@ # Camo | ||
Notice how the schema is declared right in the constructor as member variables. All _public_ member variables (variables that don't start with an underscore [_]) are added to the schema. The `'boss'` string sent to the parent constructor tells us the collection name to use for that document type. | ||
Notice how the schema is declared right in the constructor as member variables. All _public_ member variables (variables that don't start with an underscore [_]) are added to the schema. The `'companies'` string sent to the parent constructor tells us the collection name to use for that document type. | ||
Schemas can also be defined using the `schema()` method. For example, in the `constructor()` method you could use: | ||
```javascript | ||
schema({ | ||
name: String, | ||
valuation: { | ||
type: Number, | ||
default: 10000000000, | ||
min: 0 | ||
}, | ||
employees: [String], | ||
dateFounded: { | ||
type: Date, | ||
default: Date.now | ||
} | ||
}); | ||
``` | ||
Currently supported variable types are: | ||
@@ -109,0 +127,0 @@ |
@@ -62,2 +62,24 @@ "use strict"; | ||
it('should allow schema declaration via method', function(done) { | ||
class User extends Document { | ||
constructor() { | ||
super('user'); | ||
this.schema({ | ||
firstName: String, | ||
lastName: String | ||
}); | ||
} | ||
} | ||
var user = User.create(); | ||
user.firstName = 'Billy'; | ||
user.lastName = 'Bob'; | ||
user.save().then(function() { | ||
validateId(user); | ||
}).then(done, done); | ||
}); | ||
it('should allow creation of instance with data', function(done) { | ||
@@ -64,0 +86,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192763
4576
340