{"id":15141851,"url":"https://github.com/dyazincahya/sqlite-helper-nativescript","last_synced_at":"2025-09-09T06:56:02.398Z","repository":{"id":224332920,"uuid":"763018916","full_name":"dyazincahya/sqlite-helper-nativescript","owner":"dyazincahya","description":"This helper can helping you when you using SQLite in Nativescript (for NS 8 or newer)","archived":false,"fork":false,"pushed_at":"2024-10-27T12:59:40.000Z","size":67,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-29T21:54:16.426Z","etag":null,"topics":["example-code","helper","javascript","nativescript","nativescript-8","nativescript-core","sqlite"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dyazincahya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-25T10:46:34.000Z","updated_at":"2024-10-27T12:59:43.000Z","dependencies_parsed_at":"2024-02-25T11:40:23.210Z","dependency_job_id":"e590c886-ab0c-4ac9-8637-e99c2a801304","html_url":"https://github.com/dyazincahya/sqlite-helper-nativescript","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"746aee9064da1190b48470cc0c32ee66adc7a8ca"},"previous_names":["dyazincahya/example-code-sqlite-nativescript","dyazincahya/sqlite-helper-nativescript"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyazincahya%2Fsqlite-helper-nativescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyazincahya%2Fsqlite-helper-nativescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyazincahya%2Fsqlite-helper-nativescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dyazincahya%2Fsqlite-helper-nativescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dyazincahya","download_url":"https://codeload.github.com/dyazincahya/sqlite-helper-nativescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237869272,"owners_count":19379293,"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":["example-code","helper","javascript","nativescript","nativescript-8","nativescript-core","sqlite"],"created_at":"2024-09-26T09:03:05.672Z","updated_at":"2025-09-09T06:56:02.387Z","avatar_url":"https://github.com/dyazincahya.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQLite Helper Nativescript\nThis ```helper``` can helping you when you using SQLite in Nativescript\n\n\n## Dependency\nBefore you using this helper, you must be install plugin [nativescript-community/sqlite](https://github.com/nativescript-community/sqlite), cause this helper running on this plugin.\n\n## Changelogs\nSee full changelogs [here](https://github.com/dyazincahya/sqlite-helper-nativescript/releases)\n## Requirement\n- [Nativescript 8 or newer](https://nativescript.org/)\n- [nativescript-community/sqlite](https://github.com/nativescript-community/sqlite)\n\n## Folder Structure\n```\nNSProject/\n├── app/\n│   └── assets/\n│       └── db/\n│           └── your_database.db \u003c== SQLite database\n│   └── sqlite_helper.js \u003c== SQLite helper functions\n│\n```\n\n## Instructions\n1. Download file [sqlite_helper.js](https://github.com/dyazincahya/sqlite-helper-nativescript/blob/main/sqlite_helper.js) and save that file here : ```\\NSProject\\app```\n2. Create ```.db``` file using [SQLite Browser](https://sqlitebrowser.org) and create ```assets\\db``` folder on ```\\NSProject\\app```\n3. And after that put the ```your_database.db``` in ```\\NSProject\\app\\assets\\db```\n4. Open [sqlite_helper.js](https://github.com/dyazincahya/sqlite-helper-nativescript/blob/main/sqlite_helper.js) file, you can adjust configuration here\n```javascript\nconst config = {\n  databaseName: \"YOUR_DATABASE_NAME.db\", // set your database name\n  debug: true, // set false for production and set true for development\n  paths: {\n    documentsFolder: knownFolders.documents(), // Do not change this value. It is used to get the root documents directory.\n    assetsFolder: \"assets/db\", // Location of your SQLite database file. If you place an existing database here, this helper will automatically copy it to the system directory, so you don't need to manually create the database.\n  },\n};\n```\n5. import file sql_helper.js on your module, like :\n   ``` javascript\n   import { SQL__select, SQL__selectRaw, SQL__insert, SQL__update, SQL__delete, SQL__truncate, SQL__query } from \"~/sqlite_helper\";\n   ```\n6. Avaliable methode on ```sql_helper.js```\n    | Method            | Description                                                 | Return |\n    |-------------------|-------------------------------------------------------------|--------|\n    | SQL__select(...)   | for get data from table                                         | Array  |\n    | SQL__selectRaw(...) | for get data from table, same like ```SQL_select```, but here you can execute simple or advance query, like JOIN Query or etc | Array | \n    | SQL__insert(...)   | for insert data to table                                    | void   |\n    | SQL__update(...)   | for update data to table                                    | void   |\n    | SQL__delete(...)   | for delete data row from table                              | void   |\n    | SQL__truncate(...) | for clear all data on the table                             | void   |\n    | SQL__query(...)    | for execute raw query like Create new Table or Etc | ?      |\n7. For details, you can look at the [sqlite_helper.js](https://github.com/dyazincahya/sqlite-helper-nativescript/blob/main/sqlite_helper.js) file directly\n\n\n## Sample Code\n\n### TABLE\nAssummed I have a **users** table like this :\n``` sql\nCREATE TABLE \"users\" (\n\t\"id\"\tINTEGER NOT NULL UNIQUE,\n\t\"fullname\"\tTEXT NOT NULL,\n\t\"about\"\tTEXT DEFAULT NULL,\n\tPRIMARY KEY(\"id\" AUTOINCREMENT)\n)\n```\n\n#### CREATE new TABLE USERS\nBefore you can do something, make sure you already create the table. for create table in SQLite, you can use method ```SQL_query``` from ```sqlite_helper.js```, example like this :\n``` javascript\nimport { SQL__query } from \"~/sqlite_helper\";\n\nSQL__query(`CREATE TABLE IF NOT EXISTS \"users\" (\n\t\"id\"\tINTEGER NOT NULL UNIQUE,\n\t\"fullname\"\tTEXT NOT NULL,\n\t\"about\"\tTEXT DEFAULT NULL,\n\tPRIMARY KEY(\"id\" AUTOINCREMENT)\n)`);\n```\n\nWhen you make create table query, make sure you use ```IF NOT EXISTS``` in your query. This is useful to avoid double execution of your query.\n\n\n#### GET all USERS\n``` sql\nSQL__select(tableName)\n```\nI want to get all user data from the table\n``` javascript\nimport { SQL__select } from \"~/sqlite_helper\";\n\nSQL__select(\"users\").then((res) =\u003e {\n   console.log(res);\n   console.log(res.length);\n});\n```\n\n#### GET USER where FULLNAME is JOHN DUO\n```sql\nSQL__select(tableName, fields, conditionalQuery)\n```\nI want to get all user data from table by fullname is john duo\n``` javascript\nimport { SQL__select } from \"~/sqlite_helper\";\n\nSQL__select(\"users\", \"*\", \"WHERE fullname='john duo'\").then((res) =\u003e {\n   console.log(res);\n   console.log(res.length);\n});\n```\n\n#### CREATE new USER\n``` sql\nSQL__insert(tableName, data)\n```\nI want to create new user with fullname is Kang Cahya and about is Designer\n``` javascript\nimport { SQL__insert } from \"~/sqlite_helper\";\n\nSQL__insert(\"users\", [\n   { field: \"fullname\", value: \"Kang Cahya\" },\n   { field: \"about\", value: \"Designer\" }\n]);\n```\n\n#### UPDATE data USER by ID\n``` sql\nSQL__update(tableName, data, id, conditionalQuery)\n```\nI want to update field ABOUT by user ID number 3\n``` javascript\nimport { SQL__insert } from \"~/sqlite_helper\";\n\nSQL__update(\"users\", [{ field: \"about\", value: \"Tester\" }], 3);\n```\n\n#### UPDATE data USER with WHERE condition\n``` sql\nSQL__update(tableName, data, id, conditionalQuery)\n```\nI want to update field about by user ID number 3\n``` javascript\nimport { SQL__insert } from \"~/sqlite_helper\";\n\nSQL__update(\"users\", [{ field: \"about\", value: \"Tester\" }], null, \"WHERE id='3'\");\n```\n\n## My Nativescript App using SQLite Helper\n[WA Sender](https://github.com/x-labs-86/wa-sender)\n\n## More info about Sqlite\n[Sqlite Tutorial by Tutorialspoint](https://www.tutorialspoint.com/sqlite/index.htm)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyazincahya%2Fsqlite-helper-nativescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdyazincahya%2Fsqlite-helper-nativescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdyazincahya%2Fsqlite-helper-nativescript/lists"}