{"id":15538615,"url":"https://github.com/wanxianliang/react-native-sqlite-tool","last_synced_at":"2026-05-04T02:32:48.805Z","repository":{"id":57340343,"uuid":"341212115","full_name":"wanxianliang/react-native-sqlite-tool","owner":"wanxianliang","description":"a easy way to use sqlite in react native","archived":false,"fork":false,"pushed_at":"2021-03-08T01:48:23.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-18T12:06:43.630Z","etag":null,"topics":["react-native-sqlite","reactnative","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wanxianliang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-22T13:37:08.000Z","updated_at":"2021-03-08T01:48:25.000Z","dependencies_parsed_at":"2022-08-29T16:20:44.789Z","dependency_job_id":null,"html_url":"https://github.com/wanxianliang/react-native-sqlite-tool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wanxianliang/react-native-sqlite-tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanxianliang%2Freact-native-sqlite-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanxianliang%2Freact-native-sqlite-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanxianliang%2Freact-native-sqlite-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanxianliang%2Freact-native-sqlite-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wanxianliang","download_url":"https://codeload.github.com/wanxianliang/react-native-sqlite-tool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanxianliang%2Freact-native-sqlite-tool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32592460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react-native-sqlite","reactnative","sqlite","sqlite3"],"created_at":"2024-10-02T12:05:09.983Z","updated_at":"2026-05-04T02:32:48.787Z","avatar_url":"https://github.com/wanxianliang.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-sqlite-tool\n\nThis repository is based on *[react-native-sqlite-storage](https://www.npmjs.com/package/react-native-sqlite-storage)*, you should install and link react-native-sqlite-storage first\n\n# Installation\n\n```js\n npm install --save react-native-sqlite-tool\n```\n\nThen follow the instructions to use react-native-sqlite-tool;\n\n\n\n#### Steps\n\n1. Create a class for one table\n\n   ```js\n   import { SqlLite } from \"react-native-sqlite-tool\";\n   //if you use typescript\n   export interface T {\n       //primary key\n       id?: string;\n       value?: string;\n   }\n   //Set primaryKey dbName tableName createTableSql\n   class DemoSql extends SqlLite\u003cT\u003e {\n       primaryKey = \"id\";\n       dbName = \"default.db\";\n       tableName = \"todo\";\n       createTableSql = `CREATE TABLE IF NOT EXISTS todo (\n           id  varchar(32) NOT NULL,\n           value varchar(255) DEFAULT NULL,\n           PRIMARY KEY (id)\n       )`;\n       constructor() {\n           super();\n           //important\n           this.init();\n       }\n   }\n   \n   export const DemoSqlInstance = new DemoSql();\n   ```\n   \n   \n   \n2. You can use follow apis\n\n   \n\n   insert(item: T): Promise\u003cboolean\u003e;\n\n   ```js\n   import { demoSqlInstance } from \"./Demo\";\n   export interface T {\n       //primary key\n       id?: string;\n       value?: string;\n   }\n   class Todo {\n       insert(item: T) {\n           return demoSqlInstance.insert(item);\n       }\n   }\n   ```\n\n   \n\n   updateByCondition(newParams: T, conditionParams: T): Promise\u003cboolean\u003e;\n\n   ```js\n   const item={value:\"new value\"}\n   demoSqlInstance.updateByCondition(item,{id:\"123\"})\n   ```\n\n   \n\n   updateByPrimaryKey(newParams:T): Promise\u003cboolean\u003e\n\n   ```js\n   const item = { id: \"123\", value: \"new value\" }\n   demoSqlInstance.updateByPrimaryKey(item);\n   ```\n\n   deleteByPrimaryKey(primaryValue: any): Promise\u003cboolean\u003e\n\n   ```js\n   demoSqlInstance.deleteByPrimaryKey(\"123\")\n   ```\n\n   \n\n   selectByPrimaryKey(primaryValue: any): Promise\u003cT | null\u003e\n\n   ```js\n   demoSqlInstance.selectByPrimaryKey(\"123\")\n   ```\n\n   \n\n   select(selectSql?: string, orderSql?: string): Promise\u003c[] | T[]\u003e\n\n   ```js\n   demoSqlInstance.select()\n   demoSqlInstance.select(\"id=123\")\n   demoSqlInstance.select(\"id=123\",\"create_time desc\")\n   ```\n\n   \n\n   selectOne(selectSql?: string): Promise\u003cT | null\u003e\n\n   ```js\n   demoSqlInstance.selectOne(\"id=123\")\n   ```\n\n   \n\n   selectBySql(selectSql: string): Promise\u003cT[]\u003e\n\n   ```js\n   demoSqlInstance.selectBySql(\"select * from todo where id='123' order by create_time desc\")\n   ```\n\n   \n\n   executeSql(sql: string): Promise\u003cResultSet\u003e\n\n   ```js\n   demoSqlInstance.executeSql(\"select * from todo where id='123' order by create_time desc\")\n   ```\n\n   \n\nIf you like this tool, please add a star to [my Github Repo](https://github.com/wanxianliang/react-native-sqlite-tool). Thanks!\n\nThat's all. Enjoy! :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanxianliang%2Freact-native-sqlite-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanxianliang%2Freact-native-sqlite-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanxianliang%2Freact-native-sqlite-tool/lists"}