mikro-orm
Advanced tools
Comparing version 0.3.5 to 0.4.0
@@ -120,3 +120,3 @@ "use strict"; | ||
} | ||
async persist(entity, flush = false) { | ||
async persist(entity, flush = true) { | ||
await this.unitOfWork.persist(entity); | ||
@@ -123,0 +123,0 @@ if (flush) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
} | ||
async persist(entity, flush = false) { | ||
async persist(entity, flush = true) { | ||
return this.em.persist(entity, flush); | ||
@@ -11,0 +11,0 @@ } |
@@ -152,3 +152,3 @@ import { Collection as MongoCollection, Db, FilterQuery } from 'mongodb'; | ||
async persist(entity: BaseEntity, flush = false): Promise<void> { | ||
async persist(entity: BaseEntity, flush = true): Promise<void> { | ||
await this.unitOfWork.persist(entity); | ||
@@ -155,0 +155,0 @@ |
@@ -10,3 +10,3 @@ import { FilterQuery } from 'mongodb'; | ||
async persist(entity: T, flush = false): Promise<void> { | ||
async persist(entity: T, flush = true): Promise<void> { | ||
return this.em.persist(entity, flush); | ||
@@ -13,0 +13,0 @@ } |
{ | ||
"name": "mikro-orm", | ||
"version": "0.3.5", | ||
"version": "0.4.0", | ||
"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", |
@@ -93,5 +93,5 @@ # mikro-orm | ||
await orm.em.persist(book1); | ||
await orm.em.persist(book2); | ||
await orm.em.persist(book3, true); // flush everything to database | ||
await orm.em.persist(book1, false); | ||
await orm.em.persist(book2, false); | ||
await orm.em.persist(book3); // flush everything to database | ||
@@ -98,0 +98,0 @@ const authorRepository = orm.em.getRepository<Author>(Author.name); |
@@ -38,3 +38,3 @@ import { ObjectID } from 'bson'; | ||
const bible = new Book('Bible', god); | ||
await orm.em.persist(bible, true); | ||
await orm.em.persist(bible); | ||
@@ -58,5 +58,5 @@ const author = new Author('Jon Snow', 'snow@wall.st'); | ||
const repo = orm.em.getRepository<Book>(Book.name); | ||
await repo.persist(book1); | ||
await repo.persist(book2); | ||
await repo.persist(book3); | ||
await repo.persist(book1, false); | ||
await repo.persist(book2, false); | ||
await repo.persist(book3, false); | ||
await repo.flush(); | ||
@@ -158,5 +158,5 @@ | ||
await orm.em.persist(book1); | ||
await orm.em.persist(book2); | ||
await orm.em.persist(book3, true); | ||
await orm.em.persist(book1, false); | ||
await orm.em.persist(book2, false); | ||
await orm.em.persist(book3); | ||
@@ -214,3 +214,3 @@ expect(tag1._id).toBeDefined(); | ||
book.tags.remove(tag1); | ||
await orm.em.persist(book, true); | ||
await orm.em.persist(book); | ||
orm.em.clear(); | ||
@@ -222,3 +222,3 @@ book = await orm.em.findOne<Book>(Book.name, book._id); | ||
book.tags.add(tag1); | ||
await orm.em.persist(book, true); | ||
await orm.em.persist(book); | ||
orm.em.clear(); | ||
@@ -237,3 +237,3 @@ book = await orm.em.findOne<Book>(Book.name, book._id); | ||
book.tags.removeAll(); | ||
await orm.em.persist(book, true); | ||
await orm.em.persist(book); | ||
orm.em.clear(); | ||
@@ -253,3 +253,3 @@ book = await orm.em.findOne<Book>(Book.name, book._id); | ||
await repo.persist(author, true); | ||
await repo.persist(author); | ||
expect(author.id).not.toBeNull(); | ||
@@ -260,3 +260,3 @@ expect(author.version).toBe(1); | ||
author.name = 'John Snow'; | ||
await repo.persist(author, true); | ||
await repo.persist(author); | ||
expect(author.version).toBe(2); | ||
@@ -272,3 +272,3 @@ expect(author.versionAsString).toBe('v2'); | ||
const author2 = new Author('Johny Cash', 'johny@cash.com'); | ||
await repo.persist(author2, true); | ||
await repo.persist(author2); | ||
await repo.remove(author2); | ||
@@ -275,0 +275,0 @@ expect(Author.beforeDestroyCalled).toBe(2); |
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
116584