undeexcepturi
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
37 lines (27 loc) • 681 B
text/typescript
import 'reflect-metadata';
import { Entity, MikroORM, PrimaryKey, Property } from '@mikro-orm/sqlite';
interface BookData {
title: string;
}
class Book {
id!: string;
data!: BookData;
}
test(`GH issue 3221`, async () => {
const orm = await MikroORM.init({
entities: [Book],
dbName: ':memory:',
});
const newBook = orm.em.create(Book, {
id: 'testId',
data: {
title: 'testTitle',
},
});
const result = { status: 'OK', data: newBook };
expect(JSON.stringify(result)).toBe('{"status":"OK","data":{"id":"testId","data":{"title":"testTitle"}}}');
await orm.close(true);
});