I'm starting to migrate my db in an application from Realm to TypeORM with SQLite but I'm getting an Invalid regular expression: invalid group specifier name error and I try to save an item into db with a relation.
This is de code I'm trying
const produto = new Product(); produto.name = 'Produto 01'; produto.batches = []; const lote = new Batch(); lote.name = 'abc'; lote.amount = 10; lote.exp_date = new Date(); lote.price = 12.35; lote.status = 'tratado'; lote.product = produto; const productRepository = connection.getRepository(Product); const batchRepository = connection.getRepository(Batch); await productRepository.save(produto); await batchRepository.save(lote);
And those are my models
Model 1:
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';import { Batch } from './Batch';@Entity({ name: 'Products' })export class Product { @PrimaryGeneratedColumn('increment') id: number; @Column({ length: 50, }) name: string; @Column({ length: 20, nullable: true, }) code?: string; @Column({ length: 30, nullable: true, }) store?: string; @OneToMany((type) => Batch, (batch) => batch.product) batches: Batch[];}
model 2:
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';import { Product } from './Product';@Entity({ name: 'Batches' })export class Batch { @PrimaryGeneratedColumn('increment') id: number; @Column() name: string; @Column({ type: 'date', nullable: true, }) exp_date: Date; @Column({ type: 'int', nullable: true, }) amount?: number; @Column({ type: 'double precision', nullable: true, }) price?: number; @Column({ type: 'varchar', default: 'Não tratado', }) status?: string; @ManyToOne((type) => Product, (product) => product.batches) product: Product;}
I have tried change my node version when I was searching in the internet and I did't get anything different, I have also updated my metro-react-native-babel-preset to the lasted version and I'm still getting the same problem.
Can anyone help me?
React Native: 0.63.3.Node: 14.15.1Typeorm: 0.2.29