Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

camo

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camo - npm Package Compare versions

Comparing version 0.5.6 to 0.5.7

6

CHANGELOG.md

@@ -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 @@

3

lib/base-document.js

@@ -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 @@ }

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc