UNPKG

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.

40 lines (32 loc) 846 B
import { EntitySchema, MikroORM } from '@mikro-orm/sqlite'; class Test { id!: string; createdAt!: Date; } export const TestSchema = new EntitySchema<Test>({ class: Test, properties: { id: { primary: true, type: String, columnType: 'uuid', defaultRaw: 'gen_random_uuid()', }, createdAt: { type: Date, }, }, indexes: [ { properties: ['created_at'] as any }, ], }); describe('GH issue 755', () => { test('index properties need to be property names, not column names', async () => { const options = { entities: [TestSchema], dbName: ':memory:', }; const err = `Entity Test has wrong index definition: 'created_at' does not exist. You need to use property name, not column name.`; await expect(MikroORM.init(options)).rejects.toThrow(err); }); });