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

@spinajs/orm

Package Overview
Dependencies
Maintainers
1
Versions
373
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinajs/orm - npm Package Compare versions

Comparing version 1.2.165 to 1.2.175

1

lib/driver.js

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

di_1.DI.register(hydrators_1.OneToOneRelationHydrator).as(hydrators_1.ModelHydrator);
di_1.DI.register(hydrators_1.OneToManyRelationHydrator).as(hydrators_1.ModelHydrator);
di_1.DI.register(hydrators_1.JunctionModelPropertyHydrator).as(hydrators_1.ModelHydrator);

@@ -47,0 +48,0 @@ di_1.DI.register(dehydrators_1.StandardModelDehydrator).as(dehydrators_1.ModelDehydrator);

@@ -5,2 +5,5 @@ import { ModelBase } from './model';

}
export declare class OneToManyRelationHydrator extends ModelHydrator {
hydrate(target: ModelBase, values: any): void;
}
export declare class OneToOneRelationHydrator extends ModelHydrator {

@@ -7,0 +10,0 @@ hydrate(target: ModelBase, values: any): void;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JunctionModelPropertyHydrator = exports.NonDbPropertyHydrator = exports.DbPropertyHydrator = exports.OneToOneRelationHydrator = exports.ModelHydrator = void 0;
exports.JunctionModelPropertyHydrator = exports.NonDbPropertyHydrator = exports.DbPropertyHydrator = exports.OneToOneRelationHydrator = exports.OneToManyRelationHydrator = exports.ModelHydrator = void 0;
/* eslint-disable prettier/prettier */
const interfaces_1 = require("./interfaces");
const di_1 = require("@spinajs/di");

@@ -9,2 +11,27 @@ const relations_1 = require("./relations");

exports.ModelHydrator = ModelHydrator;
class OneToManyRelationHydrator extends ModelHydrator {
hydrate(target, values) {
const descriptor = target.ModelDescriptor;
if (!descriptor) {
throw new Error(`cannot hydrate model ${target.constructor.name}, no model descriptor found`);
}
for (const [key, val] of descriptor.Relations) {
if (val.Type !== interfaces_1.RelationType.Many) {
continue;
}
if (values[key] != null) {
const entity = target;
const mapRel = values[key].map((x) => {
const tEntity = !(0, di_1.isConstructor)(val.TargetModel) ? new (val.TargetModel())() : new val.TargetModel();
tEntity['__relationKey__'] = key;
return tEntity.hydrate(x);
});
const rel = new relations_1.OneToManyRelationList(target, val.TargetModel, val, mapRel);
entity[key] = rel;
delete target[val.ForeignKey];
}
}
}
}
exports.OneToManyRelationHydrator = OneToManyRelationHydrator;
class OneToOneRelationHydrator extends ModelHydrator {

@@ -17,2 +44,5 @@ hydrate(target, values) {

for (const [key, val] of descriptor.Relations) {
if (val.Type !== interfaces_1.RelationType.One) {
continue;
}
if (values[key] != null) {

@@ -19,0 +49,0 @@ const entity = target;

4

package.json
{
"name": "@spinajs/orm",
"version": "1.2.165",
"version": "1.2.175",
"description": "framework orm module",

@@ -55,3 +55,3 @@ "main": "lib/index.js",

},
"gitHead": "88312a9539d8a9650b4a47430d8ef2a0d3ebd2a2"
"gitHead": "700586c05e1d365a83180285ab5911bb88c18890"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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