question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReactNative entities are not loaded

See original GitHub issue

Issue type:

[ ] question [x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [ ] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [x] react-native [ ] expo

TypeORM version:

[x] latest [ ] @next [ ] 0.x.x (or put your version here)

//db/index.ts

import 'reflect-metadata';
import {
  Column,
  createConnection,
  Entity,
  PrimaryGeneratedColumn,
} from 'typeorm/browser';

@Entity()
export class Product {
  @PrimaryGeneratedColumn()
  public id: number;

  @Column('string')
  public name: string;

  @Column('number')
  public amount: number;

  @Column('string')
  public createdAt: string;

  @Column('boolean')
  public synced: boolean;
}

createConnection({
  type: 'react-native',
  database: 'test',
  location: 'default',
  logging: ['error', 'query', 'schema'],
  synchronize: true,
  entities: [
    Product
  ]
})
  .then(conn => {
    console.log('✅ init db', conn);
    console.log('connnnn', conn);
    const x = new Product();
    x.amount = 90;
    x.name = 'ddddddd';
    x.createdAt = 'lkjlkj';
    x.synced = false;
    conn.manager.save(x);
  })
  .catch(err => console.error(err));

// then in App.tsx 
import './db/index.ts';
Screen Shot 2019-09-10 at 3 35 07 pm

Screen Shot 2019-09-10 at 3 36 44 pm

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
mwmcodecommented, Sep 13, 2019

Solved. If you’re facing a similar issue, try changing babel decorators config from decoratorsBeforeExport: true to legacy: true

0reactions
Vlufcommented, Nov 10, 2020

Welp, I looked for that solution for ages, thanks @mustafawm

Don’t forget to clear the Metro cache when you change your babel config!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native HTML entities - Stack Overflow
I did install the package in my React Native project. I import using import Entities from 'html-entities' and put const entities = new...
Read more >
Entities no longer registered after Hot Reloading #5676 - GitHub
I've edited the title. The most common issue I've seen in this thread relates to the hot-reload feature used by development environments & ......
Read more >
JSX Gotchas | React
If you pass properties to native HTML elements that do not exist in the HTML specification, React will not render them. If you...
Read more >
Tutorial | React.js and Spring Data REST
This entity is used to track employee information — in this case, their names and job descriptions. Spring Data REST is not confined...
Read more >
Entities - typeorm - GitBook
​Column types for sqlite / cordova / react-native / expo ​ ... creates instances of entity classes when loading from the database, therefore...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found