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

typeodm

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeodm - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

package.json
{
"name": "typeodm",
"version": "0.0.5",
"version": "0.0.6",
"description": "ODM for MongoDB used Typescript",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -42,22 +42,22 @@ /**

return !!dbObject[field.name];
}).forEach(function (fieldForThisKey) {
if (dbObject[fieldForThisKey.name] instanceof Array) {
}).forEach(function (field) {
if (dbObject[field.name] instanceof Array && field.isTypeDocument()) {
(function () {
var embedTypeSchema = _this.connection.getSchema(fieldForThisKey.type);
var subCondition = _this.getSubFieldCondition(joinFields, fieldForThisKey.name);
var promises = dbObject[fieldForThisKey.name].map(function (i) {
var embedTypeSchema = _this.connection.getSchema(field.type);
var subCondition = _this.getSubFieldCondition(joinFields, field.name);
var promises = dbObject[field.name].map(function (i) {
return _this.hydrate(embedTypeSchema, i, subCondition);
});
allPromises.push(Promise.all(promises).then(function (subDocuments) {
document[fieldForThisKey.propertyName] = subDocuments;
document[field.propertyName] = subDocuments;
}));
})();
} else if (dbObject[fieldForThisKey.name] instanceof Object) {
var embedTypeSchema = _this.connection.getSchema(fieldForThisKey.type);
var subCondition = _this.getSubFieldCondition(joinFields, fieldForThisKey.name);
allPromises.push(_this.hydrate(embedTypeSchema, dbObject[fieldForThisKey.name], subCondition).then(function (subDocument) {
document[fieldForThisKey.propertyName] = subDocument;
} else if (dbObject[field.name] instanceof Object && field.isTypeDocument()) {
var embedTypeSchema = _this.connection.getSchema(field.type);
var subCondition = _this.getSubFieldCondition(joinFields, field.name);
allPromises.push(_this.hydrate(embedTypeSchema, dbObject[field.name], subCondition).then(function (subDocument) {
document[field.propertyName] = subDocument;
}));
} else {
document[fieldForThisKey.propertyName] = dbObject[fieldForThisKey.name];
document[field.propertyName] = dbObject[field.name];
}

@@ -64,0 +64,0 @@ });

@@ -30,3 +30,3 @@ /**

return array.filter(function (item) {
return _this.validate(item, type);
return !_this.validate(item, type);
}).length === 0;

@@ -33,0 +33,0 @@ }

@@ -86,3 +86,2 @@ "use strict";

if (dbField.isArray && document[propertyName] instanceof Array) {
if (_DbObjectFieldValidator.DbObjectFieldValidator.isTypeSupported(dbField.type) && _DbObjectFieldValidator.DbObjectFieldValidator.validateArray(document[propertyName], dbField.type)) throw new _exceptionWrongFieldTypeInDocumentException.WrongFieldTypeInDocumentException(dbField.type + '[]', propertyName, document);
if (dbField.isTypeDocument()) {

@@ -93,2 +92,4 @@ dbObject[propertyName] = document[propertyName].map(function (item) {

} else {
if (!_DbObjectFieldValidator.DbObjectFieldValidator.isTypeSupported(dbField.type)) throw new _exceptionFieldTypeNotSupportedException.FieldTypeNotSupportedException(dbField.type + '[]', propertyName, document);
if (!_DbObjectFieldValidator.DbObjectFieldValidator.validateArray(document[propertyName], dbField.type)) throw new _exceptionWrongFieldTypeInDocumentException.WrongFieldTypeInDocumentException(dbField.type + '[]', propertyName, document);
dbObject[propertyName] = document[propertyName];

@@ -100,5 +101,3 @@ }

if (!_DbObjectFieldValidator.DbObjectFieldValidator.isTypeSupported(dbField.type)) throw new _exceptionFieldTypeNotSupportedException.FieldTypeNotSupportedException(dbField.type, propertyName, document);
if (!_DbObjectFieldValidator.DbObjectFieldValidator.validate(document[propertyName], dbField.type)) {
throw new _exceptionWrongFieldTypeInDocumentException.WrongFieldTypeInDocumentException(dbField.type, propertyName, document);
}
if (!_DbObjectFieldValidator.DbObjectFieldValidator.validate(document[propertyName], dbField.type)) throw new _exceptionWrongFieldTypeInDocumentException.WrongFieldTypeInDocumentException(dbField.type, propertyName, document);
dbObject[dbField.name] = document[propertyName];

@@ -105,0 +104,0 @@ }

@@ -498,4 +498,4 @@ declare module 'typeodm/connection/ConnectionOptions' {

static isTypeSupported(type: string): boolean;
static validateArray(array: any[], type: string | Function): boolean;
static validate(value: any, type: string | Function): boolean;
static validateArray(array: any[], type: string): boolean;
static validate(value: any, type: string): boolean;
}

@@ -502,0 +502,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