mikro-orm
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -83,3 +83,3 @@ import { ObjectID } from 'bson'; | ||
collection: boolean; | ||
attributes: { [attribute: string]: any }; | ||
attributes?: { [attribute: string]: any }; | ||
} | ||
@@ -86,0 +86,0 @@ |
@@ -20,3 +20,3 @@ import { BaseEntity, EntityProperty } from '../BaseEntity'; | ||
meta.properties = meta.properties || {}; | ||
meta.properties[propertyName] = { ...options } as EntityProperty; | ||
meta.properties[propertyName] = Object.assign({}, options, { reference: false, collection: false }) as EntityProperty; | ||
}; | ||
@@ -23,0 +23,0 @@ } |
@@ -180,2 +180,7 @@ import { Collection as MongoCollection, Db, FilterQuery } from 'mongodb'; | ||
canPopulate(entityName: string, property: string): boolean { | ||
const props = this.metadata[entityName].properties; | ||
return property in props && props[property].reference; | ||
} | ||
/** | ||
@@ -182,0 +187,0 @@ * @todo improve this for find() operations |
@@ -30,2 +30,6 @@ import { FilterQuery } from 'mongodb'; | ||
canPopulate(property: string): boolean { | ||
return this.em.canPopulate(this.entityName, property); | ||
} | ||
create(data: any): T { | ||
@@ -32,0 +36,0 @@ return this.em.create<T>(this.entityName, data); |
{ | ||
"name": "mikro-orm", | ||
"version": "0.2.0", | ||
"version": "0.2.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", |
@@ -162,2 +162,10 @@ 'use strict'; | ||
}); | ||
test('catPopulate', async () => { | ||
const repo = orm.em.getRepository<Author>(Author.name); | ||
expect(repo.canPopulate('test')).toBe(false); | ||
expect(repo.canPopulate('name')).toBe(false); | ||
expect(repo.canPopulate('favouriteBook')).toBe(true); | ||
expect(repo.canPopulate('books')).toBe(true); | ||
}); | ||
}); | ||
@@ -164,0 +172,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98109
2460