Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@yued/typegoose

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yued/typegoose - npm Package Compare versions

Comparing version
5.4.3
to
5.4.4
+1
-1
lib/typegoose.d.ts

@@ -19,3 +19,3 @@ import 'reflect-metadata';

setModelForClass?<T>(t: T, { existingMongoose, schemaOptions, existingConnection }?: GetModelForClassOptions): mongoose.Model<InstanceType<this>> & this & T;
private buildSchema;
private buildSchema?;
}

@@ -9,4 +9,4 @@ "use strict";

const _ = require("lodash");
const data_1 = require("./data");
mongoose.Promise = global.Promise;
const data_1 = require("./data");
__export(require("./method"));

@@ -20,2 +20,58 @@ __export(require("./prop"));

class Typegoose {
constructor() {
this.buildSchema = (t, name, schemaOptions, sch) => {
const Schema = mongoose.Schema;
if (!sch) {
sch = schemaOptions ?
new Schema(data_1.schema[name], schemaOptions) :
new Schema(data_1.schema[name]);
}
else {
sch.add(data_1.schema[name]);
}
const staticMethods = data_1.methods.staticMethods[name];
if (staticMethods) {
sch.statics = Object.assign(staticMethods, sch.statics || {});
}
else {
sch.statics = sch.statics || {};
}
const instanceMethods = data_1.methods.instanceMethods[name];
if (instanceMethods) {
sch.methods = Object.assign(instanceMethods, sch.methods || {});
}
else {
sch.methods = sch.methods || {};
}
if (data_1.hooks[name]) {
const preHooks = data_1.hooks[name].pre;
preHooks.forEach((preHookArgs) => {
sch.pre(...preHookArgs);
});
const postHooks = data_1.hooks[name].post;
postHooks.forEach((postHookArgs) => {
sch.post(...postHookArgs);
});
}
if (data_1.plugins[name]) {
_.forEach(data_1.plugins[name], (plugin) => {
sch.plugin(plugin.mongoosePlugin, plugin.options);
});
}
const getterSetters = data_1.virtuals[name];
_.forEach(getterSetters, (value, key) => {
if (value.get) {
sch.virtual(key).get(value.get);
}
if (value.set) {
sch.virtual(key).set(value.set);
}
});
const indices = Reflect.getMetadata('typegoose:indices', t) || [];
for (const index of indices) {
sch.index(index.fields, index.options);
}
return sch;
};
}
getModelForClass(t, { existingMongoose, schemaOptions, existingConnection } = {}) {

@@ -52,58 +108,4 @@ const name = this.constructor.name;

}
buildSchema(t, name, schemaOptions, sch) {
const Schema = mongoose.Schema;
if (!sch) {
sch = schemaOptions ?
new Schema(data_1.schema[name], schemaOptions) :
new Schema(data_1.schema[name]);
}
else {
sch.add(data_1.schema[name]);
}
const staticMethods = data_1.methods.staticMethods[name];
if (staticMethods) {
sch.statics = Object.assign(staticMethods, sch.statics || {});
}
else {
sch.statics = sch.statics || {};
}
const instanceMethods = data_1.methods.instanceMethods[name];
if (instanceMethods) {
sch.methods = Object.assign(instanceMethods, sch.methods || {});
}
else {
sch.methods = sch.methods || {};
}
if (data_1.hooks[name]) {
const preHooks = data_1.hooks[name].pre;
preHooks.forEach((preHookArgs) => {
sch.pre(...preHookArgs);
});
const postHooks = data_1.hooks[name].post;
postHooks.forEach((postHookArgs) => {
sch.post(...postHookArgs);
});
}
if (data_1.plugins[name]) {
_.forEach(data_1.plugins[name], (plugin) => {
sch.plugin(plugin.mongoosePlugin, plugin.options);
});
}
const getterSetters = data_1.virtuals[name];
_.forEach(getterSetters, (value, key) => {
if (value.get) {
sch.virtual(key).get(value.get);
}
if (value.set) {
sch.virtual(key).set(value.set);
}
});
const indices = Reflect.getMetadata('typegoose:indices', t) || [];
for (const index of indices) {
sch.index(index.fields, index.options);
}
return sch;
}
}
exports.Typegoose = Typegoose;
//# sourceMappingURL=typegoose.js.map
{
"name": "@yued/typegoose",
"version": "5.4.3",
"version": "5.4.4",
"description": "Define Mongoose models using TypeScript classes.",

@@ -5,0 +5,0 @@ "main": "lib/typegoose.js",