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
Installations
npm install expo-sqlite expo-sqlite-wrapper
Installation for expo-sqlite
read https://docs.expo.dev/versions/latest/sdk/sqlite/
Documentations
IDatabase
export interface IDatabase<D extends string> {
useQuery: IUseQuery;
disableWatchers: () => IDatabase<D>;
enableWatchers: () => Promise<void>;
disableHooks: () => IDatabase<D>;
enableHooks: () => Promise<void>;
bulkSave: <T extends IBaseModule<D>>(tabelName: D) => Promise<BulkSave<T, D>>;
isClosed?: boolean,
tryToClose: () => Promise<boolean>;
close: () => Promise<void>;
beginTransaction: () => Promise<void>;
commitTransaction: () => Promise<void>;
rollbackTransaction: () => Promise<void>;
startRefresher: (ms: number) => void;
allowedKeys: (tableName: D) => Promise<string[]>;
asQueryable: <T extends IId<D>>(item: IId<D> | IBaseModule<D>, tableName?: D) => Promise<IQueryResultItem<T, D>>
watch: <T extends IId<D>>(tableName: D) => IWatcher<T, D>;
query: <T extends IId<D>>(tableName: D) => IQuery<T, D>;
querySelector: <T extends IId<D>>(tabelName: D) => IQuerySelector<T, D>;
find: (query: string, args?: any[], tableName?: D) => Promise<IBaseModule<D>[]>
save: <T extends IId<D>>(item: (T) | ((T)[]), insertOnly?: Boolean, tableName?: D, saveAndForget?: boolean) => Promise<T[]>;
where: <T extends IId<D>>(tableName: D, query?: any | T) => Promise<T[]>;
jsonToSql: <T>(jsonQuery: any, tableName?: D) => Promise<T[]>;
delete: (item: IId<D> | (IId<D>[]), tableName?: D) => Promise<void>;
execute: (query: string, args?: any[]) => Promise<boolean>;
dropTables: () => Promise<void>;
setUpDataBase: (forceCheck?: boolean) => Promise<void>;
tableHasChanges: <T extends IBaseModule<D>>(item: ITableBuilder<T, D>) => Promise<boolean>;
executeRawSql: (queries: SqlQuery[], readOnly: boolean) => Promise<void>;
}
Please report any issues that you find so we could make this lib even better.