DEV Community

Cover image for Expo SQLite + TypeORM

Expo SQLite + TypeORM

José Gabriel M. Bezerra on December 17, 2020

Although Expo offers a SQLite local database connection API, it is not very practical to use, especially for larger projects with more complex data...
Collapse
 
danieloi profile image
Mayowa Daniel •

Ridiculously helpful article. I've referenced it in multiple issues!

github.com/typeorm/expo-example/is...

github.com/andpor/react-native-sql...

Collapse
 
jgabriel1 profile image
José Gabriel M. Bezerra •

Thanks for sharing it! I'm glad you liked it.

Collapse
 
drlawler profile image
Dan Lawler • • Edited

Thanks for this!
Following these instructions, I ran into a small oddity:
If I create a new record, I do not receive the new record's ID with a save operation.

let result = await this.ormRepository.save(todo);

Object {
  "firstName": "first",
  "lastName": "last",
}
Enter fullscreen mode Exit fullscreen mode

Has anyone else had this issue and any recommendations?

Using:
"typeorm": "^0.2.43"
"expo-sqlite": "~10.1.0",

Collapse
 
razithebeardman profile image
Razi •

Hi, @jgabriel1 ! Is it possible you'll be updating the article with the new TypeORM API? I mean we have breaking changes here and there like no more Connection and createConnection. Can you look into it? Would be nice! Cheers!

Collapse
 
alperkay profile image
alper •

Hi Jose,

Really enjoyed reading the article. Very clear and helpful.

Thanks

Collapse
 
jgabriel1 profile image
José Gabriel M. Bezerra •

Thank you so much! I'm glad it helped you.

Collapse
 
jonasfrid profile image
jonasfrid •

Great walkthrough, thanks! FYI, typeorm v 0.2.31 has now been released with a fix to the regex related problem.

Collapse
 
jgabriel1 profile image
José Gabriel M. Bezerra •

Thanks! Yeah, I just didn't have time to test it with the new patch. I'll make sure to edit that part though.

Collapse
 
chriskrogh profile image
Christopher Krogh •

With the new typeorm (DataSource) API, you can store that in the context instead. But don't forget to initialize it before usage!

Collapse
 
lucky profile image
Lucky •

Thank you for this awesome article! Would you consider to update it to the latest expo and typeorm version? I am really struggling with getting it to work, especially the migration part.