Socket
Socket
Sign inDemoInstall

type-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-mongodb - npm Package Compare versions

Comparing version 0.0.1-beta5 to 0.0.1-beta7

1

lib/connection/Connection.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Connection = void 0;
const mongodb_1 = require("mongodb");

@@ -14,0 +15,0 @@ class Connection {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parent = exports.Field = exports.Document = void 0;
const definitionStorage_1 = require("../utils/definitionStorage");

@@ -4,0 +5,0 @@ function Document(options = {}) {

4

lib/document/DocumentTransformer.d.ts

@@ -19,4 +19,6 @@ import { DocumentClass, Newable } from '../types';

*/
static toDB<T, D extends Newable = DocumentClass>(meta: AbstractDocumentMetadata<T, D>, model: T): T & {
static toDB<T, D extends Newable = DocumentClass>(meta: AbstractDocumentMetadata<T, D>, model: Partial<T> | {
[key: string]: any;
}): T & {
[key: string]: any;
};

@@ -23,0 +25,0 @@ /**

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentTransformer = void 0;
class DocumentTransformer {

@@ -26,3 +27,3 @@ /**

dataField: 'propertyName',
map: this.createParentMapper(this.init.bind(this))
map: this.createParentMapper(this.init.bind(this)),
});

@@ -40,3 +41,3 @@ }

dataField: 'propertyName',
map: this.createParentMapper(this.init.bind(this))
map: this.createParentMapper(this.init.bind(this)),
});

@@ -54,3 +55,3 @@ }

dataField: 'propertyName',
map: this.toDB.bind(this)
map: this.toDB.bind(this),
});

@@ -69,3 +70,3 @@ }

dataField: 'fieldName',
map: this.createParentMapper(this.fromDB.bind(this))
map: this.createParentMapper(this.fromDB.bind(this)),
});

@@ -72,0 +73,0 @@ return model;

@@ -56,4 +56,6 @@ import { MongoClient, SessionOptions } from 'mongodb';

}): T;
toDB<T>(DocumentClass: DocumentClass<T> | Newable<T>, model: T): T & {
toDB<T>(DocumentClass: DocumentClass<T> | Newable<T>, model: Partial<T> | {
[key: string]: any;
}): T & {
[key: string]: any;
};

@@ -60,0 +62,0 @@ fromDB<T>(DocumentClass: DocumentClass<T> | Newable<T>, doc: Partial<T> | {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentManager = void 0;
const DocumentMetadataFactory_1 = require("./metadata/DocumentMetadataFactory");

@@ -14,0 +15,0 @@ const Connection_1 = require("./connection/Connection");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseError = void 0;
class BaseError extends Error {

@@ -4,0 +5,0 @@ constructor(message, isInternal = true) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentNotFound = void 0;
const BaseError_1 = require("./BaseError");

@@ -4,0 +5,0 @@ class DocumentNotFound extends BaseError_1.BaseError {

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./BaseError"));
__export(require("./DocumentNotFound"));
__exportStar(require("./BaseError"), exports);
__exportStar(require("./DocumentNotFound"), exports);
//# sourceMappingURL=index.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.EventManager = void 0;
const interfaces_1 = require("./interfaces");

@@ -14,0 +15,0 @@ /**

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./EventManager"));
__export(require("./interfaces"));
__exportStar(require("./EventManager"), exports);
__exportStar(require("./interfaces"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Events = void 0;
var Events;

@@ -4,0 +5,0 @@ (function (Events) {

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./decorators"));
__export(require("./DocumentManager"));
__export(require("./metadata/DocumentMetadata"));
__export(require("./metadata/EmbeddedDocumentMetadata"));
__export(require("./events"));
__export(require("./repository"));
__export(require("./types"));
__export(require("./utils/testUtils"));
__exportStar(require("./decorators"), exports);
__exportStar(require("./DocumentManager"), exports);
__exportStar(require("./metadata/DocumentMetadata"), exports);
__exportStar(require("./metadata/EmbeddedDocumentMetadata"), exports);
__exportStar(require("./events"), exports);
__exportStar(require("./repository"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./utils/testUtils"), exports);
//# sourceMappingURL=index.js.map
import { ObjectId } from 'mongodb';
import { Newable } from '../types';
import { Newable, OptionalId } from '../types';
import { FieldMetadata } from './FieldMetadata';

@@ -32,4 +32,6 @@ import { ParentDefinition } from './definitions';

*/
toDB(model: T): T & {
toDB(model: Partial<T> | {
[key: string]: any;
}): T & {
[key: string]: any;
};

@@ -45,3 +47,3 @@ /**

*/
init(props: Partial<T> | {
init(props: OptionalId<Partial<T>> | {
[key: string]: any;

@@ -48,0 +50,0 @@ }): T;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractDocumentMetadata = void 0;
const mongodb_1 = require("mongodb");

@@ -4,0 +5,0 @@ const DocumentTransformer_1 = require("../document/DocumentTransformer");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentMetadata = void 0;
const AbstractDocumentMetadata_1 = require("./AbstractDocumentMetadata");

@@ -4,0 +5,0 @@ /**

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentMetadataFactory = void 0;
const DocumentMetadata_1 = require("./DocumentMetadata");

@@ -14,0 +15,0 @@ const FieldMetadata_1 = require("./FieldMetadata");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmbeddedDocumentMetadata = void 0;
const AbstractDocumentMetadata_1 = require("./AbstractDocumentMetadata");

@@ -4,0 +5,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldMetadata = void 0;
class FieldMetadata {

@@ -4,0 +5,0 @@ constructor(opts) {

@@ -22,3 +22,5 @@ import { Cursor, ObjectId } from 'mongodb';

merge(model: T, props: Partial<T>): T;
toDB(model: T): OptionalId<T>;
toDB(model: Partial<T> | {
[key: string]: any;
}): Partial<T>;
fromDB(doc: Partial<T>): T;

@@ -67,4 +69,4 @@ /**

abstract updateByIds(ids: any[], update: UpdateQuery<T>, opts?: UpdateManyOptions): Promise<UpdateWriteOpResult>;
abstract replaceOne(filter: FilterQuery<T | any>, props: OptionalId<Partial<T>>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
abstract replaceById(id: any, props: OptionalId<Partial<T>>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
abstract replaceOne(filter: FilterQuery<T | any>, props: Partial<T>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
abstract replaceById(id: any, props: Partial<T>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
abstract deleteOne(filter: FilterQuery<T | any>, opts?: CommonOptions & {

@@ -71,0 +73,0 @@ bypassDocumentValidation?: boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractRepository = void 0;
const errors_1 = require("../errors");

@@ -4,0 +5,0 @@ /**

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./Repository"));
__exportStar(require("./Repository"), exports);
//# sourceMappingURL=index.js.map

@@ -25,4 +25,8 @@ import { Cursor, ObjectId, FindOneOptions, FindOneAndUpdateOption, FindOneAndReplaceOption, FindOneAndDeleteOption, UpdateWriteOpResult, ReplaceWriteOpResult, DeleteWriteOpResultObject } from 'mongodb';

init(props: Partial<T>): T;
toDB(model: T): OptionalId<T | any>;
fromDB(doc: Partial<T | any>): T;
toDB(model: Partial<T> | {
[key: string]: any;
}): OptionalId<T | any>;
fromDB(doc: Partial<T | any> | {
[key: string]: any;
}): T;
/**

@@ -66,4 +70,4 @@ * Creates the document id.

updateByIds(ids: any[], update: UpdateQuery<T>, opts?: UpdateManyOptions): Promise<UpdateWriteOpResult>;
replaceOne(filter: FilterQuery<T | any>, props: OptionalId<Partial<T>>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
replaceById(id: any, props: OptionalId<Partial<T>>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
replaceOne(filter: FilterQuery<T | any>, props: Partial<T>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
replaceById(id: any, props: Partial<T>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
deleteOne(filter: FilterQuery<T | any>, opts?: CommonOptions & {

@@ -70,0 +74,0 @@ bypassDocumentValidation?: boolean;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Repository = void 0;
const errors_1 = require("../errors");

@@ -81,3 +82,3 @@ const AbstractRepository_1 = require("./AbstractRepository");

return this.find({
_id: { $in: ids.map(id => this.id(id)) }
_id: { $in: ids.map((id) => this.id(id)) },
}, opts);

@@ -122,5 +123,5 @@ }

return __awaiter(this, void 0, void 0, function* () {
const models = props.map(p => this.init(p));
const models = props.map((p) => this.init(p));
const { insertedIds } = yield this.insertMany(models, opts);
return Object.keys(insertedIds).map(i => models[i]);
return Object.keys(insertedIds).map((i) => models[i]);
});

@@ -133,3 +134,3 @@ }

meta: this.metadata,
model: model
model: model,
}, () => this.collection.insertOne(doc, opts));

@@ -142,4 +143,4 @@ });

const afterInsertEvents = [];
const docs = models.map(model => this.toDB(model));
models.forEach(model => {
const docs = models.map((model) => this.toDB(model));
models.forEach((model) => {
if (!model._id) {

@@ -150,7 +151,7 @@ model._id = this.id();

meta: this.metadata,
model: model
model: model,
}));
afterInsertEvents.push(this.manager.eventManager.dispatch(events_1.Events.AfterInsert, {
meta: this.metadata,
model: model
model: model,
}));

@@ -169,3 +170,3 @@ });

filter,
update
update,
}, () => __awaiter(this, void 0, void 0, function* () {

@@ -215,3 +216,3 @@ return this.findOneAnd('Update', filter, update, Object.assign({ returnOriginal: false }, opts));

meta: this.metadata,
filter
filter,
}, () => __awaiter(this, void 0, void 0, function* () { return this.findOneAnd('Delete', filter, opts); }));

@@ -240,3 +241,3 @@ });

filter,
update
update,
}, () => this.collection.updateOne(filter, update, opts));

@@ -255,3 +256,3 @@ });

filter,
update
update,
}, () => this.collection.updateMany(filter, update, opts));

@@ -262,3 +263,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
return this.updateMany({ _id: { $in: ids.map(id => this.id(id)) } }, update, opts);
return this.updateMany({ _id: { $in: ids.map((id) => this.id(id)) } }, update, opts);
});

@@ -280,3 +281,3 @@ }

meta: this.metadata,
filter
filter,
}, () => __awaiter(this, void 0, void 0, function* () {

@@ -297,3 +298,3 @@ const result = yield this.collection.deleteOne(filter, opts);

meta: this.metadata,
filter
filter,
}, () => this.collection.deleteMany(filter, opts));

@@ -304,3 +305,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
return this.deleteMany({ _id: { $in: ids.map(id => this.id(id)) } }, opts);
return this.deleteMany({ _id: { $in: ids.map((id) => this.id(id)) } }, opts);
});

@@ -307,0 +308,0 @@ }

@@ -44,4 +44,4 @@ import { Cursor, ClientSession, FindOneOptions, FindOneAndUpdateOption, FindOneAndReplaceOption, FindOneAndDeleteOption, UpdateWriteOpResult, ReplaceWriteOpResult, DeleteWriteOpResultObject } from 'mongodb';

updateByIds(ids: any[], update: UpdateQuery<T>, opts?: UpdateManyOptions): Promise<UpdateWriteOpResult>;
replaceOne(filter: FilterQuery<T | any>, props: OptionalId<Partial<T>>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
replaceById(id: any, props: OptionalId<Partial<T>>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
replaceOne(filter: FilterQuery<T | any>, props: Partial<T>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
replaceById(id: any, props: Partial<T>, opts?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
deleteOne(filter: FilterQuery<T | any>, opts?: CommonOptions & {

@@ -48,0 +48,0 @@ bypassDocumentValidation?: boolean;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionRepository = void 0;
const AbstractRepository_1 = require("./AbstractRepository");

@@ -14,0 +15,0 @@ /**

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Session = exports.SessionState = void 0;
const TransactionRepository_1 = require("../repository/TransactionRepository");

@@ -14,0 +15,0 @@ var SessionState;

@@ -0,9 +1,4 @@

import { WithId } from 'mongodb';
export declare type DocumentClass<T = any> = Newable<WithId<T>>;
export declare type DocumentInstance<T = any> = WithId<T>;
export declare type WithId<T = any> = Omit<T, '_id'> & {
_id: any;
};
export declare type OptionalId<T = any> = Omit<T, '_id'> & {
_id?: any;
};
export declare type Newable<T = any> = new (...args: any[]) => T;

@@ -16,3 +11,3 @@ export declare type PropsOf<T = any> = {

*/
export { Db, Collection, CollectionInsertManyOptions, InsertWriteOpResult, CommonOptions, CollectionInsertOneOptions, InsertOneWriteOpResult, FindOneAndDeleteOption, FindOneAndUpdateOption, FindOneAndReplaceOption, UpdateWriteOpResult, ReplaceWriteOpResult, DeleteWriteOpResultObject, FilterQuery, UpdateQuery, UpdateManyOptions, UpdateOneOptions, ReplaceOneOptions } from 'mongodb';
export { Db, OptionalId, WithId, Collection, CollectionInsertManyOptions, InsertWriteOpResult, CommonOptions, CollectionInsertOneOptions, InsertOneWriteOpResult, FindOneAndDeleteOption, FindOneAndUpdateOption, FindOneAndReplaceOption, UpdateWriteOpResult, ReplaceWriteOpResult, DeleteWriteOpResultObject, FilterQuery, UpdateQuery, UpdateManyOptions, UpdateOneOptions, ReplaceOneOptions, } from 'mongodb';
//# sourceMappingURL=index.d.ts.map

@@ -7,3 +7,3 @@ "use strict";

var mongodb_1 = require("mongodb");
exports.Db = mongodb_1.Db;
Object.defineProperty(exports, "Db", { enumerable: true, get: function () { return mongodb_1.Db; } });
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.definitionStorage = void 0;
exports.definitionStorage = global.__TYPE_MONGODB_STORAGE__ || {

@@ -4,0 +5,0 @@ documents: new Map(),

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertNotBuiltIn = exports.isBuiltin = exports.builtins = void 0;
exports.builtins = [String, Number, Date, Boolean];

@@ -4,0 +5,0 @@ function isBuiltin(type) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPromise = void 0;
const isObject = (value) => value !== null && (typeof value === 'object' || typeof value === 'function');

@@ -4,0 +5,0 @@ function isPromise(value) {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.removeDocuments = void 0;
function removeDocuments(dm) {

@@ -14,0 +15,0 @@ return __awaiter(this, void 0, void 0, function* () {

{
"name": "type-mongodb",
"version": "0.0.1-beta5",
"version": "0.0.1-beta7",
"description": "A simple decorator based MongoDB ODM.",

@@ -27,15 +27,15 @@ "keywords": [],

"dependencies": {
"mongodb": "^3.3.2"
"mongodb": "^3.5.9"
},
"devDependencies": {
"@types/jest": "^24.0.18",
"@types/mongodb": "3.3.7",
"husky": "^3.0.5",
"jest": "^24.9.0",
"@types/jest": "^26.0.3",
"@types/mongodb": "3.5.25",
"husky": "^4.2.5",
"jest": "^26.1.0",
"mongodb-runner": "^4.7.2",
"prettier": "^1.18.2",
"pretty-quick": "^1.11.1",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"reflect-metadata": "^0.1.13",
"ts-jest": "^24.0.2",
"typescript": "^3.6.2"
"ts-jest": "^26.1.1",
"typescript": "^3.9.5"
},

@@ -42,0 +42,0 @@ "peerDependencies": {

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

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

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