{"id":18135552,"url":"https://github.com/whitfin/loki-titanium-adapter","last_synced_at":"2025-04-19T14:08:19.294Z","repository":{"id":143887504,"uuid":"189500286","full_name":"whitfin/loki-titanium-adapter","owner":"whitfin","description":"Titanium SDK adapter for the LokiJS embedded database","archived":false,"fork":false,"pushed_at":"2023-11-14T08:34:11.000Z","size":8456,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-03-15T10:51:54.767Z","etag":null,"topics":["database","json","mobile","nosql","titanium-mobile","titanium-sdk"],"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/whitfin.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":"2019-05-31T00:26:32.000Z","updated_at":"2023-05-07T01:01:01.000Z","dependencies_parsed_at":"2024-11-01T14:08:17.794Z","dependency_job_id":"78cc099a-1b0d-4af7-97a1-deb8e64a5dbc","html_url":"https://github.com/whitfin/loki-titanium-adapter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Floki-titanium-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Floki-titanium-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Floki-titanium-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Floki-titanium-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitfin","download_url":"https://codeload.github.com/whitfin/loki-titanium-adapter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246157603,"owners_count":20732644,"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":["database","json","mobile","nosql","titanium-mobile","titanium-sdk"],"created_at":"2024-11-01T14:08:12.882Z","updated_at":"2025-03-30T22:31:46.850Z","avatar_url":"https://github.com/whitfin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# loki-titanium-adapter\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/whitfin/loki-titanium-adapter/ci.yml?branch=main)](https://github.com/whitfin/loki-titanium-adapter/actions) [![Published Version](https://img.shields.io/npm/v/loki-titanium-adapter.svg)](https://npmjs.com/package/loki-titanium-adapter) [![Published Downloads](https://img.shields.io/npm/dt/loki-titanium-adapter)](https://npmjs.com/package/loki-titanium-adapter)\n\nTitanium SDK adapter for the [Loki](https://github.com/techfort/LokiJS)\nembedded database.\n\nYou can use this library to persist Loki databases inside Titanium applications\nusing the Titanium API. Everything else operates as it would in any other runtime,\nso visit the [Loki documentation](https://github.com/techfort/LokiJS) for further\ninformation.\n\n### Usage\n\nThis module is on npm, so feel free to grab from there (as well as Loki):\n\n```shell\n$ npm i lokijs loki-titanium-adapter\n```\n\nYou can then configure it inside your application pretty easily, as the\nAPI is still synchronous for the time being:\n\n```javascript\n// Load our modules\nconst Loki = require('lokijs');\nconst TitaniumAdapter = require('loki-titanium-adapter');\n\n// Construct our database instance\nconst db = new Loki('my-database', {\n    adapter: new TitaniumAdapter({\n        parent: 'data',             // subdirectory in app data\n        reader: {\n            buffer: 1024 * 1024     // max buffer during disk reads\n        },\n        writer: {\n            batch: 25               // number of documents to write in batch\n        }\n    }),\n    autoload: true,\n    autosave: true,\n    autosaveInterval: 5000,\n    autoloadCallback: function () {\n        // called when your database is loaded\n    },\n});\n```\n\nThis will save your database changes to disk every 5 seconds (configured via\nthe `autosaveInterval` parameter). In addition to this, I recommend adding a\nhook for the `pause` event to flush when the application is closed:\n\n```javascript\n// Add a pause listener to ensure flush on background\nTi.App.addEventListener('pause', function (_e) {\n    db.saveDatabase(function (e) {\n        // documents should have been flushed\n    });\n});\n```\n\nThere is also a more complete [example app](example/) available - just keep\nin mind that you need to run `npm install` before you try to run it. For any\nfurther use, check out [Loki wiki](https://github.com/techfort/LokiJS/wiki)\nas the API is exactly the same.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitfin%2Floki-titanium-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitfin%2Floki-titanium-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitfin%2Floki-titanium-adapter/lists"}