Socket
Socket
Sign inDemoInstall

iridium

Package Overview
Dependencies
4
Maintainers
1
Versions
157
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0-alpha.7 to 7.0.0-alpha.8

28

dist/lib/ModelSpecificInstance.js
"use strict";
var util = require("util");
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var _ = require("lodash");

@@ -17,9 +21,17 @@ /**

function ModelSpecificInstance(model, instanceType) {
var constructor = function (doc, isNew, isPartial) {
instanceType.call(this, model, doc, isNew, isPartial);
};
util.inherits(constructor, instanceType);
var instanceTypeConstructor = instanceType;
var virtualClass = (function (_super) {
__extends(class_1, _super);
function class_1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
_super.apply(this, [model].concat(args));
}
return class_1;
}(instanceTypeConstructor));
_.each(Object.keys(model.schema), function (property) {
if (model.transforms.hasOwnProperty(property)) {
return Object.defineProperty(constructor.prototype, property, {
return Object.defineProperty(virtualClass.prototype, property, {
get: function () {

@@ -35,3 +47,3 @@ return model.transforms[property].fromDB(this._modified[property], property, model);

}
Object.defineProperty(constructor.prototype, property, {
Object.defineProperty(virtualClass.prototype, property, {
get: function () {

@@ -46,3 +58,3 @@ return this._modified[property];

});
return constructor;
return virtualClass;
}

@@ -49,0 +61,0 @@ exports.ModelSpecificInstance = ModelSpecificInstance;

export interface Hooks<TDocument, TInstance> {
onCreating? (document: TDocument): Promise<any> | void;
onRetrieved? (document: TDocument): Promise<any> | void;
onReady? (instance: TInstance): Promise<any> | void;
onSaving?(instance: TInstance, changes: any): Promise<any> | void;
onCreating? (document: TDocument): Promise<any> | PromiseLike<any> | void;
onRetrieved? (document: TDocument): Promise<any> | PromiseLike<any> | void;
onReady? (instance: TInstance): Promise<any> | PromiseLike<any> | void;
onSaving?(instance: TInstance, changes: any): Promise<any> | PromiseLike<any> | void;
}

@@ -72,3 +72,3 @@ import {Core} from "./Core";

*/
static onCreating: (document: { _id?: any }) => Promise<any> | void;
static onCreating: (document: { _id?: any }) => Promise<any> | PromiseLike<any> | void;

@@ -80,3 +80,3 @@ /**

*/
static onRetrieved: (document: { _id?: any }) => Promise<any> | void;
static onRetrieved: (document: { _id?: any }) => Promise<any> | PromiseLike<any> | void;

@@ -87,3 +87,3 @@ /**

*/
static onReady: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>) => Promise<any> | void;
static onReady: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>) => Promise<any> | PromiseLike<any> | void;

@@ -97,3 +97,3 @@ /**

*/
static onSaving: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>, changes: any) => Promise<any> | void;
static onSaving: (instance: Instance<{ _id?: any }, Instance<{ _id?: any }, any>>, changes: any) => Promise<any> | PromiseLike<any> | void;

@@ -100,0 +100,0 @@ /**

@@ -63,3 +63,3 @@ import * as Skmatc from "skmatc";

*/
onCreating? (document: TDocument): Promise<any> | void;
onCreating? (document: TDocument): Promise<any> | PromiseLike<any> | void;

@@ -78,3 +78,3 @@ /**

*/
onRetrieved? (document: TDocument): Promise<any> | void;
onRetrieved? (document: TDocument): Promise<any> | PromiseLike<any> | void;

@@ -91,3 +91,3 @@ /**

*/
onReady? (instance: TInstance): Promise<any> | void;
onReady? (instance: TInstance): Promise<any> | PromiseLike<any> | void;

@@ -107,3 +107,3 @@ /**

*/
onSaving? (instance: TInstance, changes: any): Promise<any> | void;
onSaving? (instance: TInstance, changes: any): Promise<any> | PromiseLike<any> | void;

@@ -110,0 +110,0 @@ /**

@@ -20,11 +20,13 @@ import {Model} from "./Model";

export function ModelSpecificInstance<TDocument extends { _id?: any }, TInstance>(model: Model<TDocument, TInstance>, instanceType: InstanceImplementation<TDocument, TInstance>): ModelSpecificInstanceConstructor<TDocument, TInstance> {
let constructor = function (doc: TDocument, isNew?: boolean, isPartial?: boolean) {
instanceType.call(this, model, doc, isNew, isPartial);
};
const instanceTypeConstructor = <InstanceConstructor><any>instanceType;
let virtualClass = class extends instanceTypeConstructor {
constructor(...args) {
super(model, ...args);
}
}
util.inherits(constructor, instanceType);
_.each(Object.keys(model.schema),(property) => {
if (model.transforms.hasOwnProperty(property)) {
return Object.defineProperty(constructor.prototype, property, {
return Object.defineProperty(virtualClass.prototype, property, {
get: function () {

@@ -41,3 +43,3 @@ return model.transforms[property].fromDB(this._modified[property], property, model);

Object.defineProperty(constructor.prototype, property, {
Object.defineProperty(virtualClass.prototype, property, {
get: function () {

@@ -53,3 +55,8 @@ return this._modified[property];

return <any>constructor;
return <any>virtualClass;
}
interface InstanceConstructor {
new(...args: any[]): this;
prototype: any;
}
{
"name": "iridium",
"version": "7.0.0-alpha.7",
"version": "7.0.0-alpha.8",
"author": "Benjamin Pannell <admin@sierrasoftworks.com>",

@@ -5,0 +5,0 @@ "description": "A custom lightweight ORM for MongoDB designed for power-users",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc