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

@foxify/odin

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foxify/odin - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

12

dist/Base.d.ts

@@ -27,16 +27,14 @@ /*

import { Base as Driver } from "./drivers";
interface Base<T = any> {
new (document?: Odin.Document): Odin<T>;
constructor: typeof Odin;
interface Base<T extends object = {}> {
[key: string]: any;
id?: Driver.Id;
}
declare class Base<T = any> {
protected _isNew: boolean;
declare class Base {
protected readonly _isNew: boolean;
static readonly models: {
[name: string]: (import("./utils").ClassInterface & typeof import("./Model").default & typeof import("./base/QueryBuilder").default & typeof import("./base/Relational").default & typeof import("./GraphQL/Model").default) | undefined;
};
static isOdin: (arg: any) => arg is Odin<any>;
static isOdin: (arg: any) => arg is Odin<{}>;
static register: (...models: (import("./utils").ClassInterface & typeof import("./Model").default & typeof import("./base/QueryBuilder").default & typeof import("./base/Relational").default & typeof import("./GraphQL/Model").default)[]) => void;
constructor(document?: Odin.Document);
}
export default Base;

@@ -34,4 +34,4 @@ /*

class Base {
constructor(e = {}) {
this._isNew = !1, e.id || (this._isNew = !0);
get _isNew() {
return !this.attributes.id;
}

@@ -38,0 +38,0 @@ static get models() {

@@ -29,3 +29,3 @@ /*

import Relation from "../drivers/Relation/Base";
declare class Query<T = any, D extends Driver<T> = any> extends DB<T, D, "query"> {
declare class Query<T extends object = {}, D extends Driver<T> = any> extends DB<T, D, "query"> {
protected readonly _model: typeof Model;

@@ -32,0 +32,0 @@ protected _withTrashed: boolean;

@@ -30,27 +30,30 @@ /*

import Query from "./Query";
declare class QueryBuilder<T = any> extends Base<T> {
static query<T>(relations?: Relation[]): Query<T, any>;
interface QueryBuilder<T extends object = {}> extends Base<T> {
constructor: typeof Model;
}
declare class QueryBuilder<T extends object = {}> extends Base<T> {
static query<T extends object>(relations?: Relation[]): Query<T, any>;
/******************************* With Trashed *******************************/
static withTrashed<T>(): Query<T>;
static withTrashed<T extends object>(): Query<T>;
/****************************** With Relations ******************************/
static with<T>(...relations: string[]): Query<T>;
static with<T extends object>(...relations: string[]): Query<T>;
/*********************************** Joins **********************************/
static join<T>(table: string | typeof Model, query?: Driver.JoinQuery<T>, as?: string): Query<T>;
static join<T extends object>(table: string | typeof Model, query?: Driver.JoinQuery<T>, as?: string): Query<T>;
/******************************* Where Clauses ******************************/
static where<T>(field: string, value: any): Query<T>;
static where<T>(field: string, operator: Driver.Operator, value: any): Query<T>;
static whereLike<T>(field: string, values: any): Query<T>;
static whereNotLike<T>(field: string, values: any): Query<T>;
static whereIn<T>(field: string, values: any[]): Query<T>;
static whereNotIn<T>(field: string, values: any[]): Query<T>;
static whereBetween<T>(field: string, start: any, end: any): Query<T>;
static whereNotBetween<T>(field: string, start: any, end: any): Query<T>;
static whereNull<T>(field: string): Query<T>;
static whereNotNull<T>(field: string): Query<T>;
static where<T extends object>(field: string, value: any): Query<T>;
static where<T extends object>(field: string, operator: Driver.Operator, value: any): Query<T>;
static whereLike<T extends object>(field: string, values: any): Query<T>;
static whereNotLike<T extends object>(field: string, values: any): Query<T>;
static whereIn<T extends object>(field: string, values: any[]): Query<T>;
static whereNotIn<T extends object>(field: string, values: any[]): Query<T>;
static whereBetween<T extends object>(field: string, start: any, end: any): Query<T>;
static whereNotBetween<T extends object>(field: string, start: any, end: any): Query<T>;
static whereNull<T extends object>(field: string): Query<T>;
static whereNotNull<T extends object>(field: string): Query<T>;
/******************** Ordering, Grouping, Limit & Offset ********************/
static orderBy<T>(field: string, order?: Driver.Order): Query<T>;
static skip<T>(offset: number): Query<T>;
static offset<T>(offset: number): Query<T>;
static limit<T>(limit: number): Query<T>;
static take<T>(limit: number): Query<T>;
static orderBy<T extends object>(field: string, order?: Driver.Order): Query<T>;
static skip<T extends object>(offset: number): Query<T>;
static offset<T extends object>(offset: number): Query<T>;
static limit<T extends object>(limit: number): Query<T>;
static take<T extends object>(limit: number): Query<T>;
/*********************************** Read ***********************************/

@@ -61,10 +64,10 @@ static exists<T>(): Promise<boolean>;

static count(callback: Driver.Callback<number>): void;
static all<T>(): Promise<Array<Model<T>>>;
static all<T>(callback: Driver.Callback<Array<Model<T>>>): void;
static first<T>(): Promise<Model<T>>;
static first<T>(callback: Driver.Callback<Model<T>>): void;
static find<T>(ids: Driver.Id | Driver.Id[]): Promise<Model<T>>;
static find<T>(ids: Driver.Id | Driver.Id[], callback: Driver.Callback<Model<T>>): void;
static findBy<T>(field: string, values: any | any[]): Promise<Model<T>>;
static findBy<T>(field: string, values: any | any[], callback: Driver.Callback<Model<T>>): void;
static all<T extends object>(): Promise<Array<Model<T>>>;
static all<T extends object>(callback: Driver.Callback<Array<Model<T>>>): void;
static first<T extends object>(): Promise<Model<T>>;
static first<T extends object>(callback: Driver.Callback<Model<T>>): void;
static find<T extends object>(ids: Driver.Id | Driver.Id[]): Promise<Model<T>>;
static find<T extends object>(ids: Driver.Id | Driver.Id[], callback: Driver.Callback<Model<T>>): void;
static findBy<T extends object>(field: string, values: any | any[]): Promise<Model<T>>;
static findBy<T extends object>(field: string, values: any | any[], callback: Driver.Callback<Model<T>>): void;
static value<T>(field: string): Promise<any>;

@@ -81,4 +84,4 @@ static value<T>(field: string, callback: Driver.Callback<any>): void;

static insert<T>(items: T[], callback: Driver.Callback<number>): void;
static create<T>(item: T): Promise<Model<T>>;
static create<T>(item: T, callback: Driver.Callback<Model<T>>): void;
static create<T extends object>(item: T): Promise<Model<T>>;
static create<T extends object>(item: T, callback: Driver.Callback<Model<T>>): void;
/********************************** Updates *********************************/

@@ -85,0 +88,0 @@ save(): Promise<T>;

@@ -28,8 +28,11 @@ /*

import Relation from "../drivers/Relation/Base";
declare class Relational extends Base {
hasMany<T>(relation: string | typeof Model, localKey?: string, foreignKey?: string): Relation<T>;
hasOne<T>(relation: string | typeof Model, localKey?: string, foreignKey?: string): Relation<T>;
morphMany<T>(relation: string | typeof Model, localKey?: string, type?: string): Relation<T>;
morphOne<T>(relation: string | typeof Model, localKey?: string, type?: string): Relation<T>;
interface Relational<T extends object = {}> extends Base<T> {
constructor: typeof Model;
}
declare class Relational<T extends object = {}> extends Base<T> {
hasMany(relation: string | typeof Model, localKey?: string, foreignKey?: string): Relation<T>;
hasOne(relation: string | typeof Model, localKey?: string, foreignKey?: string): Relation<T>;
morphMany(relation: string | typeof Model, localKey?: string, type?: string): Relation<T>;
morphOne(relation: string | typeof Model, localKey?: string, type?: string): Relation<T>;
}
export default Relational;

@@ -27,5 +27,5 @@ /*

import { HasMany as Base } from "../../Relation";
declare class HasMany<T = any> extends Base {
declare class HasMany<T extends object = {}> extends Base {
load(query: Query<T>): Query<T, any>;
}
export default HasMany;

@@ -27,5 +27,5 @@ /*

import { HasOne as Base } from "../../Relation";
declare class HasOne<T = any> extends Base {
declare class HasOne<T extends object = {}> extends Base {
load(query: Query<T>): Query<T, any>;
}
export default HasOne;

@@ -27,5 +27,5 @@ /*

import { MorphMany as Base } from "../../Relation";
declare class MorphMany<T = any> extends Base {
declare class MorphMany<T extends object = {}> extends Base {
load(query: Query<T>): Query<T, any>;
}
export default MorphMany;

@@ -27,5 +27,5 @@ /*

import { MorphOne as Base } from "../../Relation";
declare class MorphOne<T = any> extends Base {
declare class MorphOne<T extends object = {}> extends Base {
load(query: Query<T>): Query<T, any>;
}
export default MorphOne;

@@ -28,3 +28,3 @@ /*

import Driver from "../Driver";
declare abstract class Relation<T = any, A = undefined> {
declare abstract class Relation<T extends object = {}, A = undefined> {
readonly model: Model;

@@ -31,0 +31,0 @@ readonly relation: typeof Model;

@@ -28,3 +28,3 @@ /*

import Relation from "../Relation/Base";
declare abstract class HasOne<T = any> extends Relation<T, "HasOne"> {
declare abstract class HasOne<T extends object = {}> extends Relation<T, "HasOne"> {
constructor(model: Model, relation: typeof Model, localKey: string | undefined, foreignKey: string | undefined, caller: (...args: any[]) => any);

@@ -31,0 +31,0 @@ insert(items: T[]): Promise<undefined>;

@@ -28,7 +28,7 @@ /*

import Relation from "../Relation/Base";
declare abstract class MorphBase<T = any, A = undefined> extends Relation<T, A> {
declare abstract class MorphBase<T extends object = {}, A = undefined> extends Relation<T, A> {
readonly type: string;
constructor(model: Model, relation: typeof Model, localKey: string | undefined, foreignKey: string | undefined, type: string, caller: (...args: any[]) => any);
protected _query(relations?: string[]): Query;
protected _query(relations?: string[]): Query<T>;
}
export default MorphBase;

@@ -28,3 +28,3 @@ /*

import Relation from "../Relation/MorphBase";
declare abstract class MorphOne<T = any> extends Relation<T, "MorphOne"> {
declare abstract class MorphOne<T extends object = {}> extends Relation<T, "MorphOne"> {
insert(items: T[]): Promise<undefined>;

@@ -31,0 +31,0 @@ insert(items: T[], callback: Driver.Callback<undefined>): void;

@@ -34,5 +34,5 @@ /*

}
declare class GraphQL<T = any> extends Base<T> {
declare class GraphQL<T extends object = {}> extends Base<T> {
static toGraphQL(): any;
}
export default GraphQL;

@@ -58,3 +58,3 @@ /*

}
interface Odin<T = any> extends Model<T> {
interface Odin<T extends object = {}> extends Model<T> {
[K: string]: any;

@@ -61,0 +61,0 @@ }

@@ -33,5 +33,5 @@ /*

import * as Types from "./types";
interface Model<T = any> extends QueryBuilder<T>, Relational, GraphQLInstance<T> {
interface Model<T extends object = {}> extends QueryBuilder<T>, Relational, GraphQLInstance<T> {
}
declare class Model<T = any> extends Base<T> implements QueryBuilder<T>, Relational, GraphQLInstance {
declare class Model<T extends object = {}> extends Base<T> implements QueryBuilder<T>, Relational, GraphQLInstance {
static DB: typeof DB;

@@ -49,6 +49,7 @@ static GraphQL: GraphQL;

static DELETED_AT: string;
static hidden: string[];
private static readonly _table;
private static readonly _schema;
static readonly driver: "MongoDB";
static on<T>(event: Odin.Event, listener: (item: Odin<T>) => void): typeof Model;
static on<T extends object>(event: Odin.Event, listener: (item: Odin<T>) => void): typeof Model;
static toString(): any;

@@ -55,0 +56,0 @@ static validate<T = object>(document: T, updating?: boolean): {

@@ -121,2 +121,3 @@ /*

return a.object.mapValues(this.attributes, (e, t) => {
if (a.array.contains(this.constructor.hidden, t)) return;
const s = this[a.getGetterName(t)];

@@ -134,2 +135,2 @@ return s ? s(e) : e;

Model.CREATED_AT = "created_at", Model.UPDATED_AT = "updated_at", Model.DELETED_AT = "deleted_at",
exports.default = Model;
Model.hidden = [], exports.default = Model;
{
"name": "@foxify/odin",
"version": "0.1.1",
"version": "0.1.2",
"description": "Active Record Model",

@@ -45,4 +45,4 @@ "author": "Ardalan Amini <ardalanamini22@gmail.com> [https://github.com/ardalanamini]",

"@types/graphql-iso-date": "^3.3.1",
"@types/mongodb": "^3.1.12",
"@types/node": "^10.12.0",
"@types/mongodb": "^3.1.14",
"@types/node": "^10.12.3",
"async": "^2.6.1",

@@ -53,5 +53,5 @@ "caller-id": "^0.1.0",

"graphql-iso-date": "^3.6.1",
"mongodb": "^3.1.8",
"mongodb": "^3.1.9",
"mysql": "^2.16.0",
"prototyped.js": "^0.20.1",
"prototyped.js": "^0.20.2",
"verifications": "^0.3.0"

@@ -62,3 +62,3 @@ },

"@types/deasync": "^0.1.0",
"@types/jest": "^23.3.7",
"@types/jest": "^23.3.9",
"@types/mysql": "^2.15.5",

@@ -69,3 +69,3 @@ "codecov": "^3.1.0",

"jest": "^23.6.0",
"mongodb-memory-server": "^2.6.2",
"mongodb-memory-server": "^2.7.0",
"rimraf": "^2.6.2",

@@ -75,3 +75,3 @@ "ts-jest": "^23.10.4",

"tslint-config-airbnb": "^5.11.0",
"typescript": "^3.1.3",
"typescript": "^3.1.6",
"uglify-es": "^3.3.9"

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