Gathering detailed insights and metrics for expo-sqlite-orm
Gathering detailed insights and metrics for expo-sqlite-orm
Gathering detailed insights and metrics for expo-sqlite-orm
Gathering detailed insights and metrics for expo-sqlite-orm
expo-sqlite-eloquent-orm
An Expo SQLite ORM
expo-sqlite-wrapper
This is an ORM, build around expo-sqlite. It will make operation like UPDATE,SELECT AND INSERT a lot easier to handle
an-expo-sqlite-orm
`npm i an-expo-sqlite-orm` or `yarn add an-expo-sqlite-orm`
expo-ink
A lightweight, type-safe, and asynchronous SQLite ORM for expo-sqlite
npm install expo-sqlite-orm
Typescript
Module System
Node Version
NPM Version
TypeScript (99.1%)
JavaScript (0.9%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
144 Stars
174 Commits
35 Forks
6 Watchers
16 Branches
3 Contributors
Updated on Jun 25, 2025
Latest Version
2.2.0
Package Id
expo-sqlite-orm@2.2.0
Unpacked Size
30.94 kB
Size
8.68 kB
File Count
30
NPM Version
10.5.2
Node Version
20.13.1
Published on
May 16, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
It is a simple ORM utility to use with expo sqlite
Warn: it works only on iOS and Android. Web is not supported (SEE)
yarn add expo-sqlite-orm
You need to provide 3 things:
databaseName
: Name of the database to be created/used by expo SQLitetableName
: The name of the tablecolumnMapping
: The columns for the model and their types
type
, primary_key
, autoincrement
, not_null
, unique
, default
1import { Text } from '@components' 2import { ColumnMapping, columnTypes, IStatement, Migrations, Repository, sql } from 'expo-sqlite-orm' 3import React, { useMemo, useState } from 'react' 4import { ScrollView } from 'react-native' 5 6import { RootTabScreenProps } from '../../navigation/types' 7 8/** 9 * Expo Sqlite ORM V2 - Usage example 10 */ 11 12interface Animal { 13 id: number 14 name: string 15 color: string 16 age: number 17 another_uid?: number 18 timestamp?: number 19} 20 21const columMapping: ColumnMapping<Animal> = { 22 id: { type: columnTypes.INTEGER }, 23 name: { type: columnTypes.TEXT }, 24 color: { type: columnTypes.TEXT }, 25 age: { type: columnTypes.NUMERIC }, 26 another_uid: { type: columnTypes.INTEGER }, 27 timestamp: { type: columnTypes.INTEGER, default: () => Date.now() }, 28} 29 30const statements: IStatement = { 31 '1662689376195_create_animals': sql` 32 CREATE TABLE animals ( 33 id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 34 name TEXT NOT NULL, 35 color TEXT, 36 age NUMERIC, 37 another_uid TEXT UNIQUE, 38 timestamp INTEGER 39 );`, 40} 41 42const databaseName = 'dbName' 43 44export function MeusServicosScreen({ navigation }: RootTabScreenProps<'MeusServicos'>) { 45 const [animals, setAnimals] = useState<Animal[]>([]) 46 const migrations = useMemo(() => new Migrations(databaseName, statements), []) 47 48 const animalRepository = useMemo(() => { 49 return new Repository(databaseName, 'animals', columMapping) 50 }, []) 51 52 const onPressRunMigrations = async () => { 53 await migrations.migrate() 54 } 55 56 const onPressReset = async () => { 57 await migrations.reset() 58 setAnimals([]) 59 } 60 61 const onPressInsert = () => { 62 animalRepository.insert({ name: 'Bob', color: 'Brown', age: 2 }).then((createdAnimal) => { 63 console.log(createdAnimal) 64 }) 65 } 66 67 const onPressQuery = () => { 68 animalRepository.query({ where: { age: { gte: 1 } } }).then((foundAnimals) => { 69 console.log(foundAnimals) 70 setAnimals(foundAnimals) 71 }) 72 } 73 74 return ( 75 <ScrollView> 76 <Text type="text2" onPress={onPressRunMigrations}> 77 Migrate 78 </Text> 79 <Text type="text2" onPress={onPressReset}> 80 Reset Database 81 </Text> 82 <Text type="text2" onPress={onPressInsert}> 83 Insert Animal 84 </Text> 85 <Text type="text2" onPress={onPressQuery}> 86 List Animals 87 </Text> 88 <Text type="text2">{JSON.stringify(animals, null, 1)}</Text> 89 </ScrollView> 90 ) 91} 92
1const props: Animal = { 2 name: 'Bob', 3 color: 'Brown', 4 age: 2 5} 6 7animalRepository.insert(props)
1const id = 1 2animalRepository.find(id)
or
1animalRepository.findBy({ age: { equals: 12345 }, color: { contains: '%Brown%' } })
1const props = { 2 id: 1 // required 3 age: 3 4} 5 6animalRepository.update(props)
1const id = 1 2animalRepository.destroy(id)
1animalRepository.destroyAll()
1const options = { 2 columns: 'id, name', 3 where: { 4 id: { in: [1, 2, 3, 4] }, 5 age: { gt: 2, lt: 10 } 6 }, 7 page: 2, 8 limit: 30, 9 order: { name: 'ASC' } 10} 11 12animalRepository.query(options)
The property
page
is applied only if you pass thelimit
as well
Where operations
=
,<>
,<
,<=
,>
,>=
,LIKE
IN (?)
NOT IN (?)
1myCustomMethod() { 2 const sql = 'SELECT * FROM table_name WHERE status = ?' 3 const params = ['active'] 4 return animalRepository.databaseLayer.executeSql(sql, params).then(({ rows }) => rows) 5}
1const itens = [{id: 1, color: 'green'}, {id: 2, color: 'red'}] 2animalRepository.databaseLayer.bulkInsertOrReplace(itens).then(response => { 3 console.log(response) 4})
1import * as SQLite from 'expo-sqlite/legacy' 2import { Migrations, sql } from 'expo-sqlite-orm' 3 4const statements: IStatement = { 5 '1662689376195_init': sql`CREATE TABLE animals (id TEXT, name TEXT);`, 6 '1662689376196_add_age_column': sql`ALTER TABLE animals ADD age NUMERIC;`, 7 '1662689376197_add_color_column': sql`ALTER TABLE animals ADD color TEXT;` 8} 9 10const migrations = new Migrations('databaseName', statements) 11await migrations.migrate()
1const migrations = new Migrations('databaseName', statements) 2await migrations.reset()
page
is not specified in the query
paramsautoincrement
property to be optional1docker-compose run --rm bump # patch 2docker-compose run --rm bump --minor # minor 3 4git push 5git push --tags
1docker-compose run --rm app install 2docker-compose run --rm app test
This project is licensed under MIT License
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 3/24 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More