Typeorm with react native Typeorm with react native sqlite sqlite

Typeorm with react native


Unfortunately import from 'typeorm' module does not work because react-native projects does not use node platform excatly. Imports from 'typeorm/browser' will work. Here is a sample project.: https://github.com/typeorm/react-native-example

Make sure you create a connection object that does not use any references to project file system. Avoid using something like:

import { CountSession } from '../biopro-mobile-database/entities/count_session';   const connection = await createConnection({            name: 'liteDb_3',            type: 'react-native',            database: 'biopro_mobile.sqlite',            location: 'default',            synchronize: false,            logging: true,            entities: ["../biopro-mobile-database/entities/**/*.ts"],          })

Avoid entities: ["../biopro-mobile-database/entities//*.ts"],**Instead use something like:

import { EquipmentCounted } from '../biopro-mobile-database/entities/equipment_counted';import { CountSession } from '../biopro-mobile-database/entities/count_session';   const connection = await createConnection({            name: 'liteDb_3',            type: 'react-native',            database: 'biopro_mobile.sqlite',            location: 'default',            synchronize: false,            logging: true,            entities: [              CountSession,              EquipmentCounted,            ],          })