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

mikro-orm

Package Overview
Dependencies
Maintainers
1
Versions
3403
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mikro-orm - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

tests/repositories/AuthorRepository.ts

1

dist/BaseEntity.d.ts

@@ -36,2 +36,3 @@ import { ObjectID } from 'bson';

};
customRepository: any;
}

2

dist/EntityFactory.d.ts

@@ -13,4 +13,4 @@ import { EntityManager } from './EntityManager';

create<T extends BaseEntity>(entityName: string, data: any): T;
createReference<T extends BaseEntity>(entityName: string, id: string): T;
private initEntity<T>(entity, properties, data, exclude?);
createReference<T extends BaseEntity>(entityName: string, id: string): T;
private extractConstructorParams<T>(meta, data);

@@ -17,0 +17,0 @@ private loadMetadata();

@@ -43,2 +43,7 @@ "use strict";

}
createReference(entityName, id) {
const ref = this.create(entityName, { id });
ref['_initialized'] = false;
return ref;
}
initEntity(entity, properties, data, exclude = []) {

@@ -77,7 +82,2 @@ // process base entity properties first

}
createReference(entityName, id) {
const ref = this.create(entityName, { id });
ref['_initialized'] = false;
return ref;
}
extractConstructorParams(meta, data) {

@@ -84,0 +84,0 @@ return meta.constructorParams.map((k) => {

@@ -41,2 +41,3 @@ import { Collection as MongoCollection, Db, FilterQuery } from 'mongodb';

private processPopulate(entity, populate);
create<T extends BaseEntity>(entityName: string, data: any): T;
}

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

if (!this.repositoryMap[entityName]) {
// TODO customRepository support
this.repositoryMap[entityName] = new EntityRepository_1.EntityRepository(this, entityName);
const meta = this.metadata[entityName];
if (meta.customRepository) {
this.repositoryMap[entityName] = new meta.customRepository(this, entityName);
}
else {
this.repositoryMap[entityName] = new EntityRepository_1.EntityRepository(this, entityName);
}
}

@@ -129,3 +134,8 @@ return this.repositoryMap[entityName];

}
create(entityName, data) {
const entity = this.entityFactory.create(entityName, data);
entity['_initialized'] = false;
return entity;
}
}
exports.EntityManager = EntityManager;

@@ -17,3 +17,4 @@ import { FilterQuery } from 'mongodb';

remove(where: any): Promise<number>;
create(data: any): T;
count(where: any): Promise<number>;
}

@@ -23,2 +23,5 @@ "use strict";

}
create(data) {
return this.em.create(this.entityName, data);
}
async count(where) {

@@ -25,0 +28,0 @@ return this.em.count(this.entityName, where);

@@ -10,2 +10,1 @@ export * from './MikroORM';

export * from './decorators/Property';
export * from './decorators/hooks';

@@ -15,2 +15,1 @@ "use strict";

__export(require("./decorators/Property"));
__export(require("./decorators/hooks"));

@@ -85,2 +85,3 @@ import { ObjectID } from 'bson';

properties: { [property: string]: EntityProperty };
customRepository: any;
}

@@ -53,2 +53,9 @@ import { readdirSync } from 'fs';

createReference<T extends BaseEntity>(entityName: string, id: string): T {
const ref = this.create<T>(entityName, { id });
(ref as any)['_initialized'] = false;
return ref;
}
private initEntity<T extends BaseEntity>(entity: T, properties: any, data: any, exclude: string[] = []): void {

@@ -91,9 +98,2 @@ // process base entity properties first

createReference<T extends BaseEntity>(entityName: string, id: string): T {
const ref = this.create<T>(entityName, { id });
(ref as any)['_initialized'] = false;
return ref;
}
private extractConstructorParams<T extends BaseEntity>(meta: EntityMetadata, data: any): any[] {

@@ -100,0 +100,0 @@ return meta.constructorParams.map((k: string) => {

@@ -38,4 +38,9 @@ import { Collection as MongoCollection, Db, FilterQuery } from 'mongodb';

if (!this.repositoryMap[entityName]) {
// TODO customRepository support
this.repositoryMap[entityName] = new EntityRepository<T>(this, entityName);
const meta = this.metadata[entityName];
if (meta.customRepository) {
this.repositoryMap[entityName] = new meta.customRepository(this, entityName);
} else {
this.repositoryMap[entityName] = new EntityRepository<T>(this, entityName);
}
}

@@ -160,2 +165,9 @@

create<T extends BaseEntity>(entityName: string, data: any): T {
const entity = this.entityFactory.create<T>(entityName, data);
entity['_initialized'] = false;
return entity;
}
}

@@ -30,2 +30,6 @@ import { FilterQuery } from 'mongodb';

create(data: any): T {
return this.em.create<T>(this.entityName, data);
}
async count(where: any): Promise<number> {

@@ -32,0 +36,0 @@ return this.em.count(this.entityName, where);

@@ -10,1 +10,2 @@ export * from './MikroORM';

export * from './decorators/Property';
export * from './decorators/hooks';
{
"name": "mikro-orm",
"version": "0.1.0",
"version": "0.1.1",
"description": "Simple typescript mongo ORM for node.js based on data-mapper, unit-of-work and identity-map patterns",

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

@@ -21,4 +21,5 @@ # mikro-orm

import { Author } from './Author';
import { BookRepository } from './BookRepository';
@Entity({ collection: 'books-table' })
@Entity({ collection: 'books-table', customRepository: BookRepository })
export class Book extends BaseEntity {

@@ -25,0 +26,0 @@

import { BaseEntity, Collection, Entity, OneToMany, Property } from '../../lib';
import { Book } from './Book';
import { AuthorRepository } from '../repositories/AuthorRepository';
@Entity()
@Entity({ customRepository: AuthorRepository })
export class Author extends BaseEntity {

@@ -6,0 +7,0 @@

@@ -7,2 +7,3 @@ 'use strict';

import { Book } from './entities/Book';
import { AuthorRepository } from './repositories/AuthorRepository';

@@ -94,2 +95,9 @@ let orm: MikroORM;

});
test('should provide custom repository', async () => {
const repo = orm.em.getRepository<Author>(Author.name) as AuthorRepository;
expect(repo).toBeInstanceOf(AuthorRepository);
expect(repo.magic).toBeInstanceOf(Function);
expect(repo.magic('test')).toBe('111 test 222');
});
});

@@ -96,0 +104,0 @@

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