{"id":21428683,"url":"https://github.com/spikef/sync-sqlite","last_synced_at":"2025-07-14T10:32:24.016Z","repository":{"id":57376202,"uuid":"62375190","full_name":"Spikef/sync-sqlite","owner":"Spikef","description":"SQLite operation based on sql.js.","archived":false,"fork":false,"pushed_at":"2016-07-04T18:46:53.000Z","size":67,"stargazers_count":4,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-14T05:53:07.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Spikef.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":"2016-07-01T07:53:02.000Z","updated_at":"2021-09-18T08:51:11.000Z","dependencies_parsed_at":"2022-09-17T16:00:30.328Z","dependency_job_id":null,"html_url":"https://github.com/Spikef/sync-sqlite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spikef%2Fsync-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spikef%2Fsync-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spikef%2Fsync-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spikef%2Fsync-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Spikef","download_url":"https://codeload.github.com/Spikef/sync-sqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225970900,"owners_count":17553410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-22T22:14:22.473Z","updated_at":"2024-11-22T22:14:23.091Z","avatar_url":"https://github.com/Spikef.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sync-sqlite\n\n[![Build Status](https://travis-ci.org/Spikef/sync-sqlite.svg?branch=master)](https://travis-ci.org/Spikef/sync-sqlite)\n[![Coverage Status](https://coveralls.io/repos/github/Spikef/sync-sqlite/badge.svg?branch=master)](https://coveralls.io/github/Spikef/sync-sqlite)\n[![NPM Version](http://img.shields.io/npm/v/sync-sqlite.svg?style=flat)](https://www.npmjs.org/package/sync-sqlite)\n[![NPM Downloads](https://img.shields.io/npm/dm/sync-sqlite.svg?style=flat)](https://www.npmjs.org/package/sync-sqlite)\n\n[点此阅读中文文档](https://github.com/Spikef/sync-sqlite/blob/master/README_CN.md)\n\nSQLite operation based on `sql.js`.\n\n## Install\n\n```bash\n$ npm install sync-sqlite\n```\n\n## Usage\n\n```javascript\nvar options = {\n    dbPath: './test.db',\n    autoSave: true\n};\nvar SQLite = require('sync-sqlite');\nvar db = new SQLite(options);\n```\n\n## Methods\n\n### connect\n\nConnect and open database. If the target dbPath doesn't exist, it will be created automatically.\n\n### table(tables)\n\nSet what table you want to operate.\n\n**tables:** Table name, one table use string, more than one use array\n\n### createTable(table, fields)\n\nCreate a new data table in current database.\n\n**table:** Table name\n\n**fields:** Fields list(array)\n\n### clearTable(table)\n\nClear all data in the table and reset index.\n\n**table:** Table name\n\n### deleteTable(table)\n\nDelete the table.\n\n**table:** Table name\n\n### appendFields(table, fields)\n\nAppend fields to the table.\n\n**table:** Table name\n\n**fields:** Fields list(array)\n\n### select(tables, fields, where, orders, limit)\n\nQuery data, return a RecordSet object.\n\n**tables:** Table name, string or array(more than one table)\n\n**fields:** Fields, string or array\n\n**where:** Optional, query condition\n\n**orders:** Optional, order by\n\n**limit:** Optional, query count\n\n### sel(fields, where, orders, limit)\n\nQuery data, return a RecordSet object.\n\n### insert(tables, fields)\n\nInsert data, return a JSON object. `ar` means the affected rows, `id` means the inserted id.\n\n**tables:** Table name, string or array(more than one table)\n\n**fields:** Fields, json object(key is field name, value is field value).\n\n### ins(fields)\n\nInsert data, return a JSON object. `ar` means the affected rows, `id` means the inserted id.\n\n### update(tables, fields, where)\n\nUpdate data, return a JSON object. `ar` means the affected rows.\n\n**tables:** Table name, string or array(more than one table)\n\n**fields:** Fields, json object(key is field name, value is field value).\n\n**where:** Optional, query condition\n\n### upd(fields, where)\n\nUpdate data, return a JSON object. `ar` means the affected rows.\n\n### remove(tables, fields, where, orders, limit)\n\nRemove data, return a JSON object. `ar` means the affected rows.\n\n**tables:** Table name, string or array(more than one table)\n\n**fields:** Fields, string or array\n\n**where:** Optional, query condition\n\n**orders:** Optional, order by\n\n**limit:** Optional, query count\n\n### rem(fields, where, orders, limit)\n\nRemove data, return a JSON object. `ar` means the affected rows.\n\n### runSQL(sql)\n\nExecute sql string, the return values are the same as above.\n\n### execute(sql)\n\nExecute sql string, the return values are:\n\nIf not query, return undefined.\n\nIf query, return an array contains the query result.\n\n### page(sql, pageIndex, pageSize)\n\nPagination query.\n\n**sql:** The query sql string\n**pageIndex:** Page index, start from 1\n**pageSize:** Record count per page\n\n### getTables()\n\nGet all table and fields information.\n\n### getFields(table)\n\nGet all fields information.\n\n**table:** Table name\n\n### getVersion()\n\nGet sqlite database version, such as `3.11.0`。\n\n## RecordSet\n\nThe query operation will return RecordSet object.\n\n### toJSON(index)\n\nConvert query result to JSON. If you specify the index, it will return a json at the index, otherwise return the whole array, if no data, return null.\n\n### toArray(index)\n\nConvert query result to Array. If you specify the index, it will return a array at the index, otherwise return the whole array, if no data, return empty array.\n\n### forEach(callback)\n\nLoop the query result.\n\n### each(callback)\n\nLoop the query result.\n\n## Examples\n\nPlease check the examples directory to get more idea.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspikef%2Fsync-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspikef%2Fsync-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspikef%2Fsync-sqlite/lists"}