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

xpress-mongo

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xpress-mongo - npm Package Compare versions

Comparing version 0.0.60 to 0.0.61

2

package.json
{
"name": "xpress-mongo",
"version": "0.0.60",
"version": "0.0.61",
"description": "Light Weight ODM for mongoDb",

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

@@ -280,6 +280,6 @@ import ObjectCollection = require('object-collection');

*/
static async new<T extends XMongoModel>(data: StringToAnyObject, save = true): Promise<T> {
static async new<T extends typeof XMongoModel>(this: T, data: StringToAnyObject, save = true): Promise<InstanceType<T>> {
const record = this.make(data);
if (save) await record.save();
return <T>record;
return record;
}

@@ -294,4 +294,4 @@

*/
static make<T extends XMongoModel>(data: StringToAnyObject): T {
return <T>(new this()).set(data);
static make<T extends typeof XMongoModel>(this: T, data: StringToAnyObject): InstanceType<T> {
return (new this()).set(data) as InstanceType<T>;
}

@@ -822,4 +822,4 @@

*/
static use(data: StringToAnyObject): XMongoModel {
const model: XMongoModel | any = new this();
static use<T extends typeof XMongoModel>(this: T, data: StringToAnyObject): InstanceType<T> {
const model = new this();
model.emptyData();

@@ -832,4 +832,4 @@ // Set Original Property

for (const key of this.append) {
if (typeof <StringToAnyObject>model[key] === "function") {
model.set(key, <StringToAnyObject>model[key]())
if (typeof (model as StringToAnyObject)[key] === "function") {
model.set(key, (model as StringToAnyObject)[key]())
}

@@ -839,3 +839,3 @@ }

return <XMongoModel>model;
return model as InstanceType<T>;
}

@@ -990,3 +990,3 @@

*/
static findOne<T extends XMongoModel>(query: (StringToAnyObject | FilterQuery<any>) = {}, options: FindOneOptions<any> | boolean = {}, raw = false): Promise<T | null> {
static findOne<T extends typeof XMongoModel>(this: T, query: (StringToAnyObject | FilterQuery<any>) = {}, options: FindOneOptions<any> | boolean = {}, raw = false): Promise<InstanceType<T> | null> {

@@ -1005,3 +1005,3 @@ if (typeof options === "boolean") {

return resolve(this.use(data) as T);
return resolve(this.use(data) as InstanceType<T>);
});

@@ -1019,3 +1019,3 @@ });

*/
static findById(_id: any, options: FindOneOptions<any> = {}, isTypeObjectId = true): Promise<XMongoModel | null> {
static findById<T extends typeof XMongoModel>(this: T, _id: any, options: FindOneOptions<any> = {}, isTypeObjectId = true): Promise<InstanceType<T> | null> {
let where;

@@ -1202,3 +1202,3 @@ if (typeof _id === "string" || !isTypeObjectId) {

*/
static fromArray(query: FunctionWithRawArgument | any[], interceptor: boolean | { (lists: Array<any>): any } = false): XMongoModel[] | Promise<any[]> {
static fromArray<T extends typeof XMongoModel>(this: T, query: FunctionWithRawArgument | any[], interceptor: boolean | { (lists: Array<any>): any } = false): InstanceType<T>[] | Promise<any[]> {
if (typeof query === "function") {

@@ -1205,0 +1205,0 @@ return new Promise((resolve, reject) => {

@@ -20,3 +20,3 @@ const {connector, connection} = require('./connection');

*/
const guest = new Users().set({
const guest = Users.use({
type: 'guest',

@@ -23,0 +23,0 @@ first_name: 'Hello',

@@ -127,3 +127,3 @@ import ObjectCollection = require('object-collection');

*/
static new<T extends XMongoModel>(data: StringToAnyObject, save?: boolean): Promise<T>;
static new<T extends typeof XMongoModel>(this: T, data: StringToAnyObject, save?: boolean): Promise<InstanceType<T>>;
/**

@@ -136,3 +136,3 @@ * Creates instance.

*/
static make<T extends XMongoModel>(data: StringToAnyObject): T;
static make<T extends typeof XMongoModel>(this: T, data: StringToAnyObject): InstanceType<T>;
/**

@@ -248,3 +248,3 @@ * Check if id is a valid id

*/
static use(data: StringToAnyObject): XMongoModel;
static use<T extends typeof XMongoModel>(this: T, data: StringToAnyObject): InstanceType<T>;
/**

@@ -291,3 +291,3 @@ * Has One relationship

*/
static findOne<T extends XMongoModel>(query?: (StringToAnyObject | FilterQuery<any>), options?: FindOneOptions<any> | boolean, raw?: boolean): Promise<T | null>;
static findOne<T extends typeof XMongoModel>(this: T, query?: (StringToAnyObject | FilterQuery<any>), options?: FindOneOptions<any> | boolean, raw?: boolean): Promise<InstanceType<T> | null>;
/**

@@ -300,3 +300,3 @@ * Fetches the first document that matches id provided.

*/
static findById(_id: any, options?: FindOneOptions<any>, isTypeObjectId?: boolean): Promise<XMongoModel | null>;
static findById<T extends typeof XMongoModel>(this: T, _id: any, options?: FindOneOptions<any>, isTypeObjectId?: boolean): Promise<InstanceType<T> | null>;
/**

@@ -382,5 +382,5 @@ * Count All the documents that match query.

*/
static fromArray(query: FunctionWithRawArgument | any[], interceptor?: boolean | {
static fromArray<T extends typeof XMongoModel>(this: T, query: FunctionWithRawArgument | any[], interceptor?: boolean | {
(lists: Array<any>): any;
}): XMongoModel[] | Promise<any[]>;
}): InstanceType<T>[] | Promise<any[]>;
/**

@@ -387,0 +387,0 @@ * A helper to fetch result as array.

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