Comparing version 0.4.0 to 0.4.1
@@ -35,2 +35,8 @@ ## [Unreleased] | ||
## [0.4.1] - 2017-12-27 | ||
### Removed | ||
* tenant param from insertOne() and insertMany() since is not needed anumore because is already attached to the Document object | ||
## [0.4.0] - 2017-12-27 | ||
@@ -229,2 +235,3 @@ | ||
[0.4.1]: https://github.com/Yonirt/moltyjs/compare/v0.4.0...v0.4.1 | ||
[0.4.0]: https://github.com/Yonirt/moltyjs/compare/v0.3.0...v0.4.0 | ||
@@ -231,0 +238,0 @@ [0.3.0]: https://github.com/Yonirt/moltyjs/compare/v0.2.1...v0.3.0 |
@@ -309,10 +309,12 @@ 'use strict'; | ||
*/ | ||
insertOne(tenant, doc, options = {}) { | ||
insertOne(doc, options = {}) { | ||
var _this = this; | ||
return _asyncToGenerator(function* () { | ||
if (!tenant && typeof tenant != 'string') throw new Error('Should specify the tenant name (String), got: ' + tenant); | ||
const Document = require('../document'); | ||
if (!(doc instanceof Document)) throw new Error('The document should be a proper Document instance'); | ||
if (!doc._tenant && typeof doc._tenant != 'string') throw new Error('The document must specify the tenant name (String), got: ' + doc._tenant); | ||
const tenant = doc._tenant; | ||
// Assign default options to perform the inserOne query | ||
@@ -413,7 +415,6 @@ const insertOneOptions = Object.assign({}, defaultInsertOneOptions, options); | ||
*/ | ||
insertMany(tenant, docs, options = {}) { | ||
insertMany(docs, options = {}) { | ||
var _this2 = this; | ||
return _asyncToGenerator(function* () { | ||
if (!tenant && typeof tenant != 'string') throw new Error('Should specify the tenant name (String), got: ' + tenant); | ||
if (!(docs instanceof Array)) throw new Error('The documents should be a proper Array instance with documents'); | ||
@@ -423,3 +424,6 @@ if (docs.length <= 0) throw new Error('The documents Array should not be empty'); | ||
if (!(docs[0] instanceof Document)) throw new Error('Elements of the Array should be Document instances'); | ||
if (!docs[0]._tenant && typeof docs[0]._tenant != 'string') throw new Error('The document must specify the tenant name (String), got: ' + docs[0]._tenant); | ||
const tenant = docs[0]._tenant; | ||
// Assign default options to perform the inserMany query | ||
@@ -426,0 +430,0 @@ const insertManyOptions = Object.assign({}, defaultInsertManyOptions, options); |
{ | ||
"name": "moltyjs", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A tiny ODM for MongoDB with multy tenancy support.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -0,1 +1,3 @@ | ||
[![npm version](https://badge.fury.io/js/moltyjs.svg)](https://badge.fury.io/js/moltyjs) | ||
# What is moltyjs? | ||
@@ -156,7 +158,10 @@ | ||
newDoc = TestModel.new({ | ||
email: 'test@moltyjs.com', | ||
password: '1321321', | ||
name: 'Michael Scott', | ||
}); | ||
newDoc = TestModel.new( | ||
{ | ||
email: 'test@moltyjs.com', | ||
password: '1321321', | ||
name: 'Michael Scott', | ||
}, | ||
'test', | ||
); | ||
@@ -178,3 +183,3 @@ // You can call static methods from the document itself | ||
## Examples: | ||
Examples: | ||
@@ -224,3 +229,3 @@ ```javascript | ||
## Examples: | ||
Examples: | ||
@@ -307,7 +312,10 @@ ```javascript | ||
newDoc = TestModel.new({ | ||
email: 'test@moltyjs.com', | ||
password: '1321321', | ||
name: 'Michael Scott', | ||
}); | ||
newDoc = TestModel.new( | ||
{ | ||
email: 'test@moltyjs.com', | ||
password: '1321321', | ||
name: 'Michael Scott', | ||
}, | ||
'test', | ||
); | ||
``` | ||
@@ -368,5 +376,4 @@ | ||
### `insertOne(tenant, doc, options = {})` | ||
### `insertOne(doc, options = {})` | ||
* {String} `tanant` Tenant name | ||
* {Document} `doc` Document instance object | ||
@@ -379,10 +386,9 @@ * {Object} `options` Optional settings | ||
```javascript | ||
const res = await connection.insertOne('tenant_test', newDoc); | ||
const res = await connection.insertOne(newDoc); | ||
// Document || Error | ||
``` | ||
### `insertMany(tenant, docs, options = {})` | ||
### `insertMany(docs, options = {})` | ||
* {String} `tanant` Tenant name | ||
* [{Document}] `docs` Array of Document instances | ||
* [{Document}] `docs` Array of Document instances of the same model and for the same tenant | ||
* {Object} `options` Optional settings | ||
@@ -398,5 +404,5 @@ * {Boolean} `moltyClass` (true by default) True if you want the results as MoltyJs Document class | ||
name: 'Dwight Schrute', | ||
}); | ||
}, 'test'); | ||
const res = await connection.insertMany('tenant_test', [newDoc, newDoc2], {moltyClass: false}); | ||
const res = await connection.insertMany([newDoc, newDoc2], {moltyClass: false}); | ||
// Document || Error | ||
@@ -403,0 +409,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
78804
1381
448