{"id":13773225,"url":"https://github.com/rla/docstore","last_synced_at":"2025-03-06T01:22:16.408Z","repository":{"id":11823789,"uuid":"14376707","full_name":"rla/docstore","owner":"rla","description":"Document-oriented in-memory database for Prolog.","archived":false,"fork":false,"pushed_at":"2021-01-23T16:28:31.000Z","size":38,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-11T20:56:27.229Z","etag":null,"topics":["database","swi-prolog"],"latest_commit_sha":null,"homepage":null,"language":"Prolog","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/rla.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}},"created_at":"2013-11-13T21:17:57.000Z","updated_at":"2023-06-19T00:32:50.000Z","dependencies_parsed_at":"2022-09-03T00:12:04.363Z","dependency_job_id":null,"html_url":"https://github.com/rla/docstore","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/rla%2Fdocstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fdocstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fdocstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rla%2Fdocstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rla","download_url":"https://codeload.github.com/rla/docstore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242128907,"owners_count":20076277,"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","swi-prolog"],"created_at":"2024-08-03T17:01:13.061Z","updated_at":"2025-03-06T01:22:16.379Z","avatar_url":"https://github.com/rla.png","language":"Prolog","funding_links":[],"categories":["Database"],"sub_categories":[],"readme":"# docstore\n\nDocument-oriented transactional in-memory database for SWI-Prolog. Documents are represented\nusing [dicts](http://www.swi-prolog.org/pldoc/man?section=dicts) and are organized\ninto collections. Each document is assigned an unique identifier (`$id`) that can\nbe later used to retrieve/update/remove the document.\n\nData is stored in-memory and database changes are journaled onto the disk. This\nworks similar to [persistency.pl](http://www.swi-prolog.org/pldoc/doc/home/vnc/prolog/lib/swipl/library/persistency.pl)\nexcept that the high-level interface is different (documents vs. predicates) and the library\nis thread-safe. The library supports transactions and hooks (`before_save`, `before_remove`).\n\n[![Build Status](https://travis-ci.org/rla/docstore.svg)](https://travis-ci.org/rla/docstore)\n\n## Example usage\n\nOpen database:\n\n    ?- ds_open('test.db').\n    true.\n\nInsert some data:\n\n    ?- ds_insert(vehicle{year: 1926, make: chrysler, model: imperial}).\n    ?- ds_insert(vehicle{year: 1953, make: chevrolet, model: corvette}).\n    ?- ds_insert(vehicle{year: 1954, make: cadillac, model: fleetwood}).\n\nQuery all documents in a collection:\n\n    ?- ds_all(vehicle, List).\n    List = [\n        vehicle{'$id':'f3012622-cacb-4d7f-a22a-c36305274a80',\n            make:chrysler, model:imperial, year:1926},\n        vehicle{'$id':'23418d47-5835-41ff-a6b8-8748f3b2163e',\n            make:chevrolet, model:corvette, year:1953},\n        vehicle{'$id':'8c79f80f-d43e-4fad-a1bb-5fca23a195e0',\n            make:cadillac, model:fleetwood, year:1954}].\n\nQuery by condition:\n\n    ?- ds_find(vehicle, year=1953, List).\n    List = [\n        vehicle{'$id':'23418d47-5835-41ff-a6b8-8748f3b2163e',\n            make:chevrolet, model:corvette, year:1953}].\n\nUpdate:\n\n    ?- ds_update(vehicle{'$id':'23418d47-5835-41ff-a6b8-8748f3b2163e', year: 1954}).\n    ?- ds_col_get(vehicle, '23418d47-5835-41ff-a6b8-8748f3b2163e', Vehicle).\n    Vehicle = vehicle{'$id':'23418d47-5835-41ff-a6b8-8748f3b2163e',\n        make:chevrolet, model:corvette, year:1954}.\n\nRemove:\n\n    ?- ds_col_remove(vehicle, '23418d47-5835-41ff-a6b8-8748f3b2163e').\n    ?- ds_all(vehicle, List).\n    List = [\n        vehicle{'$id':'f3012622-cacb-4d7f-a22a-c36305274a80',\n            make:chrysler, model:imperial, year:1926},\n        vehicle{'$id':'8c79f80f-d43e-4fad-a1bb-5fca23a195e0',\n            make:cadillac, model:fleetwood, year:1954}].\n\n## Transactions\n\nTransactions are built-in to guarantee database consistency. Each predicate that\nmodifies database (such as `ds_insert`) starts implicit transaction. Transactions\ncan be nested. In that case only the outer transaction has effect. To use explicit\ntransaction, use `ds_transactional/1`. Example:\n\n    fail_test:-\n        ds_insert(vehicle{year: 1926, make: chrysler, model: imperial}),\n        fail.\n\nRunning this through `ds_transactional/1` causes no changes made by\n`ds_insert` to be persisted as the predicate ends with `fail`. Same would\nhappen when the predicate threw an exception.\n\n## Hooks\n\nTwo kinds of hooks are supported: before save and before remove. Hooks are\nregistered using the `ds_hook/3` predicate. Hook that fails or throws an\nexception will abort the current transaction. Transactions inside hooks\nare joined with the currently running transaction.\n\n## Installation\n\nRequires SWI-Prolog 7.x.\n\n    pack_install(docstore).\n\n## Changelog\n\n * 2021-01-23 version 2.0.2 - fix `load_tx_begin` not being a predicate indicator.\n * 2014-04-22 version 1.0.1 - use dot notation instead of get_dict_ex/3.\n * 2014-01-02 version 1.0.0 - switch to dicts, more tests, transactions.\n * 2013-12-23 versions 0.0.1/0.0.2 - docstore working with option lists.\n\n### Version 2.x\n\n * `ds_remove/1` is removed, provided untyped access, use `ds_col_remove/2`.\n * `ds_remove/2` is removed, use `ds_col_remove_cond/2`.\n * `ds_id/2` can be used to extract document id.\n * `ds_get/2` and `ds_get/3` are removed, provided untyped access, use `ds_col_get/3`\n   and `ds_col_get/4`.\n\n## API documentation\n\nSee \u003chttp://packs.rlaanemets.com/docstore/doc/\u003e.\n\n## Debugging\n\nEnable debugging with `debug(docstore)` on the console.\n\n## Known issues\n\n * Disk representation is not very compact. This could be improved.\n * `before_save` hooks are only given updated values not whole document. This might change.\n\n## Bug reports/feature requests\n\nPlease send bug reports/feature request through the GitHub project [page](https://github.com/rla/docstore).\n\n## License\n\nThe MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frla%2Fdocstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frla%2Fdocstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frla%2Fdocstore/lists"}