New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bridge-mongo

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bridge-mongo - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

26

dist/Example/Controllers/publication.d.ts

@@ -0,1 +1,23 @@

/// <reference types="mongoose/types/aggregate" />
/// <reference types="mongoose/types/callback" />
/// <reference types="mongoose/types/collection" />
/// <reference types="mongoose/types/connection" />
/// <reference types="mongoose/types/cursor" />
/// <reference types="mongoose/types/document" />
/// <reference types="mongoose/types/error" />
/// <reference types="mongoose/types/helpers" />
/// <reference types="mongoose/types/middlewares" />
/// <reference types="mongoose/types/indizes" />
/// <reference types="mongoose/types/models" />
/// <reference types="mongoose/types/mongooseoptions" />
/// <reference types="mongoose/types/pipelinestage" />
/// <reference types="mongoose/types/populate" />
/// <reference types="mongoose/types/query" />
/// <reference types="mongoose/types/schemaoptions" />
/// <reference types="mongoose/types/schematypes" />
/// <reference types="mongoose/types/session" />
/// <reference types="mongoose/types/types" />
/// <reference types="mongoose/types/utility" />
/// <reference types="mongoose/types/validation" />
/// <reference types="mongoose" />
import { Controller } from 'bridgets';

@@ -6,3 +28,3 @@ export declare class Publication extends Controller {

text: string;
user: string;
user: import("mongoose").Schema.Types.ObjectId;
};

@@ -17,3 +39,3 @@ }) => Promise<{

text: string;
user: string;
user: import("mongoose").Schema.Types.ObjectId;
} & {

@@ -20,0 +42,0 @@ _id: string;

65

dist/Example/Controllers/user.d.ts

@@ -25,55 +25,2 @@ import { Controller } from 'bridgets';

})>, never>;
findOne: import("bridgets").BridgeHandler<({ body }: {
body: {
_id: string;
};
}) => Promise<{
error: {
status: 404;
name: "Document not found";
};
} | ({
name: string;
} & {
_id: string;
})>, never>;
exists: import("bridgets").BridgeHandler<({ query }: {
query: {
_id: string;
};
}) => Promise<{
exists: boolean;
}>, never>;
count: import("bridgets").BridgeHandler<({ query }: {
query: {
_id: string;
};
}) => Promise<{
total: number;
}>, never>;
updateOne: import("bridgets").BridgeHandler<({ query, body }: {
body: {
event: boolean;
};
query: {
_id: string;
};
}) => Promise<{
error: {
status: 404;
name: "Document not found";
};
} | ({
name: string;
email: string;
} & {
_id: string;
})>, never>;
deleteOne: import("bridgets").BridgeHandler<({ query }: {
query: {
_id: string;
};
}) => Promise<{
deleted: boolean;
}>, never>;
getPage: import("bridgets").BridgeHandler<({ query }: {

@@ -85,12 +32,6 @@ query: {

}) => Promise<{
data: ({
createdAt: Date;
name: string;
email: string;
age: number | undefined;
} & {
data: {
_id: string;
} & {
ddd: number;
})[];
sah: Date;
}[];
total: number;

@@ -97,0 +38,0 @@ skip: number;

@@ -16,23 +16,24 @@ "use strict";

});
findOne = this.handler({
body: ZO({ _id }),
resolve: async ({ body }) => DB_1.DB.user.findOne({ list: '' }, { proj: { name: 1 } }),
});
exists = this.handler({
query: ZO({ _id }),
resolve: ({ query }) => DB_1.DB.user.exists(query),
});
count = this.handler({
query: ZO({ _id }),
resolve: async ({ query }) => DB_1.DB.user.count(query),
});
updateOne = this.handler({
query: ZO({ _id }),
body: ZO({ event: zod_1.z.boolean() }),
resolve: async ({ query, body }) => DB_1.DB.user.updateOne(query, { emailPreferences: body }, { proj: { name: 1, email: 1 } }),
});
deleteOne = this.handler({
query: ZO({ _id }),
resolve: async ({ query }) => DB_1.DB.user.deleteOne(query),
});
// findOne = this.handler({
// body: ZO({ _id }),
// resolve: async ({ body }) => DB.user.findOne({ list: '' }, { proj: { name: 1 } }),
// });
// exists = this.handler({
// query: ZO({ _id }),
// resolve: ({ query }) => DB.user.exists(query),
// });
// count = this.handler({
// query: ZO({ _id }),
// resolve: async ({ query }) => DB.user.count(query),
// });
// updateOne = this.handler({
// query: ZO({ _id }),
// body: ZO({ event: z.boolean() }),
// resolve: async ({ query, body }) =>
// DB.user.updateOne(query, { emailPreferences: body }, { proj: { name: 1, email: 1 } }),
// });
// deleteOne = this.handler({
// query: ZO({ _id }),
// resolve: async ({ query }) => DB.user.deleteOne(query),
// });
getPage = this.handler({

@@ -45,10 +46,14 @@ query: ZO({ name: name.optional(), email: email.optional() }),

.addFields({ ddd: { $dayOfMonth: '$createdAt' } })
.match({ ddd: 90 })
// .match({'dd'})
// .match({''})
// .match(query || {})
// .lookup(
// { from: 'publication', as: 'yo', let: { userId: '$_id' } },
// (pub, { userId }) => pub.match({ $expr: { $eq: ['$user', userId] } }).project({ text: 1 })
// //pub.match({ $expr: { $eq: ['$user', userId] } }).project({ text: 1 })
// // pub.match({$expr: {$eq: [""]}})
// )
.lookup({ from: 'publication', as: 'yo', let: { userId: '$_id' } }, (pub, { userId }) => pub.project({ text: 1 })
//pub.match({ $expr: { $eq: ['$user', userId] } }).project({ text: 1 })
// pub.match({$expr: {$eq: [""]}})
)
.unwind({ path: '$yo' })
.addFields({ dda: { $assign: '$yo.text' } })
.group({ _id: '$name', sah: '$createdAt' })
// .match({"sah"})
// .match({''})
// .unwind({ path: '$yo', preserveNullAndEmptyArrays: false })

@@ -55,0 +60,0 @@ // .project({ name: 1, age: 1, yo: { text: 1 } })

@@ -0,4 +1,26 @@

/// <reference types="mongoose/types/aggregate" />
/// <reference types="mongoose/types/callback" />
/// <reference types="mongoose/types/collection" />
/// <reference types="mongoose/types/connection" />
/// <reference types="mongoose/types/cursor" />
/// <reference types="mongoose/types/document" />
/// <reference types="mongoose/types/error" />
/// <reference types="mongoose/types/helpers" />
/// <reference types="mongoose/types/middlewares" />
/// <reference types="mongoose/types/indizes" />
/// <reference types="mongoose/types/models" />
/// <reference types="mongoose/types/mongooseoptions" />
/// <reference types="mongoose/types/pipelinestage" />
/// <reference types="mongoose/types/populate" />
/// <reference types="mongoose/types/query" />
/// <reference types="mongoose/types/schemaoptions" />
/// <reference types="mongoose/types/schematypes" />
/// <reference types="mongoose/types/session" />
/// <reference types="mongoose/types/types" />
/// <reference types="mongoose/types/utility" />
/// <reference types="mongoose/types/validation" />
/// <reference types="mongoose" />
export declare const DBZod: {
user: {
_id: import("zod").ZodType<string, import("zod").ZodTypeDef, string>;
_id: import("zod").ZodType<import("mongoose").Schema.Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Schema.Types.ObjectId>;
name: import("zod").ZodType<string, import("zod").ZodTypeDef, string>;

@@ -18,5 +40,5 @@ email: import("zod").ZodType<string, import("zod").ZodTypeDef, string>;

publication: {
_id: import("zod").ZodType<string, import("zod").ZodTypeDef, string>;
_id: import("zod").ZodType<import("mongoose").Schema.Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Schema.Types.ObjectId>;
text: import("zod").ZodType<string, import("zod").ZodTypeDef, string>;
user: import("zod").ZodType<string, import("zod").ZodTypeDef, string>;
user: import("zod").ZodType<import("mongoose").Schema.Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Schema.Types.ObjectId>;
createdAt: import("zod").ZodType<Date, import("zod").ZodTypeDef, Date>;

@@ -28,3 +50,3 @@ updatedAt: import("zod").ZodType<Date, import("zod").ZodTypeDef, Date>;

user: import("../../Lib").default<{
_id: string;
_id: import("mongoose").Schema.Types.ObjectId;
name: string;

@@ -42,5 +64,5 @@ email: string;

publication: import("../../Lib").default<{
_id: string;
_id: import("mongoose").Schema.Types.ObjectId;
text: string;
user: string;
user: import("mongoose").Schema.Types.ObjectId;
createdAt: Date;

@@ -47,0 +69,0 @@ updatedAt: Date;

@@ -0,1 +1,2 @@

import { Schema } from 'mongoose';
import { DBTypes } from './type';

@@ -9,5 +10,5 @@ import { ZodType } from 'zod';

export declare const publicationDB: BridgeMongoModel<{
_id: string;
_id: Schema.Types.ObjectId;
text: string;
user: string;
user: Schema.Types.ObjectId;
createdAt: Date;

@@ -14,0 +15,0 @@ updatedAt: Date;

@@ -0,4 +1,5 @@

import { ObjectId } from 'mongoose';
export declare type DBTypes = {
user: {
_id: string;
_id: ObjectId;
name: string;

@@ -16,5 +17,5 @@ email: string;

publication: {
_id: string;
_id: ObjectId;
text: string;
user: string;
user: ObjectId;
createdAt: Date;

@@ -21,0 +22,0 @@ updatedAt: Date;

@@ -0,1 +1,2 @@

import { Schema } from 'mongoose';
import { DBTypes } from './type';

@@ -9,3 +10,3 @@ import { ZodType } from 'zod';

export declare const userDB: BridgeMongoModel<{
_id: string;
_id: Schema.Types.ObjectId;
name: string;

@@ -12,0 +13,0 @@ email: string;

@@ -11,2 +11,3 @@ import { Model as MongoModel, PipelineStage } from 'mongoose';

lookup: AggI<ModelI, AllDBI>['lookup'];
group: AggI<ModelI, AllDBI>['group'];
unset: AggI<ModelI, AllDBI>['unset'];

@@ -13,0 +14,0 @@ limit: AggI<ModelI, AllDBI>['limit'];

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

};
group = (group) => new Aggregate(this.mongoModel, [...this.pipe, { $group: group }]);
unset = (unset) => new Aggregate(this.mongoModel, [...this.pipe, { $unset: unset }]);

@@ -35,0 +36,0 @@ limit = (limit) => new Aggregate(this.mongoModel, [...this.pipe, { $limit: limit }]);

import { PipelineStage } from 'mongoose';
import { Filter, FilterParam } from '../utility';
import { Filter } from '../utility';
declare type KeysWithValsOfType<T, V> = keyof {
[P in keyof T as T[P] extends V ? P : never]: P;
} & string;
declare type FlatPath<T> = keyof {
[key in keyof T as T[key] extends Record<any, any> ? `${key extends string ? key : ''}.${FlatPath<T[key]> extends string ? FlatPath<T[key]> : ''}` : keyof T]: 1;
};
declare type ValueFromFlatPath<Data, Path> = Path extends `${infer A & keyof Data & string}.${infer B}` ? A extends keyof Data ? ValueFromFlatPath<Data[A], B> : 'Wrong Path' : Path extends keyof Data ? Data[Path] : 'Wrong Path';
declare type DateOperator = '$year' | '$month' | '$dayOfMonth' | '$hour' | '$minute' | '$second' | '$millisecond' | '$dayOfYear' | '$dayOfWeek' | '$week';

@@ -11,4 +15,7 @@ declare type proj = 0 | 1;

};
declare type AddAssign<ModelI> = {
$assign?: `$${FlatPath<ModelI> & string}`;
};
declare type AddFields<ModelI> = {
[key: string]: AddDate<ModelI>;
[key: string]: AddDate<ModelI> | AddAssign<ModelI> | string | number;
};

@@ -26,2 +33,7 @@ declare type Projection<ModelI> = {

};
declare type Group<ModelI> = {
_id: null | `$${keyof ModelI & string}`;
} & {
[key: string]: `$${keyof ModelI & string}`;
};
export interface AggI<ModelI, AllDBI extends Record<string, any>> {

@@ -37,3 +49,5 @@ pipe: PipelineStage[];

addFields: <Proj extends AddFields<ModelI>>(p: Proj) => AggI<ModelI & {
[key in keyof Proj]: number;
[key in keyof Proj]: Proj[key] extends AddDate<ModelI> ? number : Proj[key] extends AddAssign<ModelI> & {
$assign: `$${infer Path}`;
} ? ValueFromFlatPath<ModelI, Path> : Proj[key];
}, AllDBI>;

@@ -49,3 +63,3 @@ project: <Proj extends Projection<ModelI>>(p: Proj) => AggI<{

}, AllDBI>;
match: <MP extends Filter<ModelI>>(match: FilterParam<MP, ModelI>) => AggI<ModelI, AllDBI>;
match: <MP extends Filter<ModelI>>(match: MP) => AggI<ModelI, AllDBI>;
limit: (limit: number) => AggI<ModelI, AllDBI>;

@@ -55,2 +69,5 @@ unset: <UN extends Array<keyof ModelI> | keyof ModelI>(unsetP: UN) => AggI<{

}, AllDBI>;
group: <G extends Group<ModelI>>(p: G) => AggI<{
[key in keyof G]: G[key] extends `$${infer KeyFromModel}` ? KeyFromModel extends keyof ModelI ? ModelI[KeyFromModel] : never : never;
}, AllDBI>;
lookup: <Let extends Record<string, `$${keyof ModelI extends string ? keyof ModelI : never}`>, From extends keyof AllDBI & string, NewModel, AS extends string = From>(p1: {

@@ -57,0 +74,0 @@ from: From;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const test = {
a: 4,
nb: 8,
sah: [1, 2],
too: {
po: 9,
pal: {
op: '',
},
},
};
// { [key: string]: { [key in dateOperator]: `$${KeysWithValsOfType<ModelI, Date>}` } };

@@ -4,0 +15,0 @@ // type ProjectionParam<P, ModelI> = P & StrictPropertyCheck<P, Projection<ModelI>, 'Only property of the model are allowed'>;

@@ -9,6 +9,10 @@ export declare type StrictPropertyCheck<T, TExpected, TError> = Exclude<keyof T, keyof TExpected> extends never ? {} : TError;

};
declare type numbers = '0' | '1';
declare type WithDollar<T extends string> = `$${T}`;
export declare type FlatPath<T> = keyof {
[key in keyof T as T[key] extends Record<any, any> ? `${key extends string ? key : ''}.${FlatPath<T[key]> extends string ? FlatPath<T[key]> : ''}` : keyof T]: 1;
};
export declare type CreateData<ModelI> = Omit<ModelI, '_id' | 'createdAt' | 'updatedAt'>;
export declare type CreateDataParam<C, ModelI> = C & StrictPropertyCheck<C, CreateData<ModelI>, 'Only property of the model are allowed'>;
export declare type Filter<Data> = {
export declare type Filter<Data, R = {}> = {
[key in keyof Data]?: Partial<Data[key]> extends Array<infer TArr> | undefined ? TArr | Data[key] : Data[key] | {

@@ -23,5 +27,5 @@ $gt?: Data[key];

} & {
[key in keyof Data as Data[key] extends Array<any> ? `${key extends string ? key : ''}.${number}` : never]?: Data[key] extends Array<infer SubData> ? Filter<SubData> | {
[key in `${KeysWithValsOfType<Required<Data>, Array<R>> & string}.${numbers}`]?: {
$exists?: boolean;
} : never;
};
} & {

@@ -28,0 +32,0 @@ $expr?: Filter<Data>;

{
"name": "bridge-mongo",
"version": "0.0.12",
"version": "0.0.13",
"description": "A mongodb ORM on top of mongoose that match perfectly with the bridgets framework",

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

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 not supported yet

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 not supported yet

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 not supported yet

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 not supported yet

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