{"id":13651436,"url":"https://github.com/eder-ai/compass-db","last_synced_at":"2025-04-22T22:31:15.029Z","repository":{"id":57204583,"uuid":"116165280","full_name":"eder-ai/compass-db","owner":"eder-ai","description":null,"archived":false,"fork":false,"pushed_at":"2018-03-26T17:58:11.000Z","size":7,"stargazers_count":29,"open_issues_count":3,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-15T09:30:01.373Z","etag":null,"topics":["blockstack","gaia"],"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/eder-ai.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":"2018-01-03T17:44:13.000Z","updated_at":"2023-09-08T17:34:42.000Z","dependencies_parsed_at":"2022-09-18T01:00:51.665Z","dependency_job_id":null,"html_url":"https://github.com/eder-ai/compass-db","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/eder-ai%2Fcompass-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eder-ai%2Fcompass-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eder-ai%2Fcompass-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eder-ai%2Fcompass-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eder-ai","download_url":"https://codeload.github.com/eder-ai/compass-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250333931,"owners_count":21413480,"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":["blockstack","gaia"],"created_at":"2024-08-02T02:00:49.449Z","updated_at":"2025-04-22T22:31:14.805Z","avatar_url":"https://github.com/eder-ai.png","language":"JavaScript","readme":"# CompassDB\n\nCompassDB is an open soruce ORM for [Gaia] (https://github.com/blockstack/gaia) storage.\n\n It provides an abstraction of a database over the file-based storage system provided by Gaia.\nIt’s compatible with the Blockstack ecosystem which leverages the Gaia storage, to provide database methods for developers.\n## Getting Started\nTo get started,\n\u003e `npm install compass-db`\n\nOr you can download the compassDB-min-js  from here.\n\n### Example: Initialization\n\n```javascript\n// Create reliable connection with CompassDB\nconst compassdb = new CompassDB();\n\n// Creating a collection\nconst collection = compassdb.newCollectionInstance(COLLECTION_NAME, true);\ncollection.createCollection()\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n});\n\n```\n## Core Components\n\nCompassDB uses abstraction concepts to render the database and create a relationship with the actual Gaia storage.\n\nThe two main components are:\n\n* **Documents:** These are the basic structural unit of the database. Every document contains a group of key-value pairs. These are used to identify and manage request of files in the storage.\nA basic constructor declaration is done with `constructor(collectionName, encrypt_decrypt).`\n\n* **Collections** Collections are described as a set of Documents. Every Collection instance contains the name of all the Documents within that set and their status.\n\nTo setup a new connection, we must first create an instance of CompassDB followed by creating a new collection for usage(as shown in the example previously).\n\n## Methods\n### Collection Operations\n\n* **createCollection:** Creates a new collection.\n* **dropCollection:** Drops an existing collection\n\n### Document Operations\n\n* **insert:** inserts value within a document\n* **update:** updates document with help of Id reference\n* **findOne:** Finds document within collection\n* **findAll:** Finds all documents with certain properties within a collection\n* **deleteOne:** Deletes one document from the collection\n* **deleteAll:** Deletes all documents with certain properties within a collection\n\n### Types of Response\n\n* **successResponse:**\nStatus code: 200, Status text: `SUCCESS` , Description and Payload\n\n* **failureResponse:**\nStatus code: 400, Status text: `FAILURE`, Description\n\n\n\n-----------------------\n## createCollection\n `.createCollection()` creates a new collection. It fetches the list of existing collections and verifies if the requested collection exists or not.\n\n\n#### Arguments:\nNo arguments; But to instantiate a Collection object, collectionName, encrypt_decrypt these two infomration are required.\n\n#### Returns:\nPromise.\n\n#### Example:\n```javascript\nconst collection = compassdb.newCollectionInstance(COLLECTION_NAME, true);\ncollection.createCollection()\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n\n## dropCollection\n`.dropCollection()` implements a soft delete of the collection. It changes the `activeState` to false.\n\n#### Arguments:\nNo arguments;\n\n#### Returns:\nPromise.\n\n\n#### Example:\n```javascript\ncollection.dropCollection()\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n\n## insert\n\n`.insert(newDocument)` puts a document into the collection.\n\n#### Arguments:\n `newDocument`, reference to the document that is to be pushed into the collection.\n\n#### Returns:\nPromise.\n\nIf successful then will return the inserted `Document Object` in successResponse.payload\n\n#### Example:\n```javascript\ncollection.insert(newDocument)\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n\n## update\n\n`.update(id,queries)` is used for updating documents already inserted in a collection.\n\n#### Arguments:\n`id` and `query`.\nThe id is used to find the particular document in the collection and after that, the requested queries are processed if eligible.\n\n#### Returns:\nPromise.\n\nIf successful then will return the updated `Document Object` in successResponse.payload\n\n#### Example:\n```javascript\nconst id = 1;\ncollection.update(id, { 'title' : 'CompassDB', 'note' : 'Most promising ORM' })\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n\n## findOne\n\n`.findOne(queries)` fetches the first document in the collection that contains the given queries.\n\n#### Arguments:\n `query`.\nThe search result brings the first document that matches the description of the key-value pair of the queries. If not found, it gives a `failureResponse` in return.\n\n#### Returns:\n Promise\n\n If successful then will return the `Document Object` in successResponse.payload\n\n#### Example:\n```javascript\ncollection.findOne({ 'title' : 'CompassDB', 'note' : 'Most promising ORM' })\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n\n## findAll\n\n`.findAll(queries)` fetches all the documents in the collection that contains the given queries as an array of object.\n\n#### Arguments:\n `query`.\nThe search result brings all documents that match the description of the key-value pair of the queries. If not a single document found, it gives a `failureResponse` in return.\n\n#### Returns:\n Promise\n\n If successful then will return an array of `Document Objects` in successResponse.payload\n\n#### Example:\n```javascript\ncollection.findAll({ 'title' : 'CompassDB', 'note' : 'Most promising ORM' })\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n\n## deleteOne\n\n`.deleteOne(query)` removes the first document that is found matching the query. Here, the `isActive` state of the document is changed to false.\n\n#### Arguments:\n`query`\ndeletes the first document that matches the description of the key-value pair of the queries. If not found, it gives a `failureResponse` in return.\n\n#### Returns:\n Promise.\n\n  If successful then will return the deleted `Document Object` in successResponse.payload\n\n#### Example:\n\n```javascript\ncollection.deleteOne({ 'title' : 'another', 'note' : 'test' })\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n\n## deleteAll\n\n`.deleteAll(query)` removes the all the documents that match the query. Here, the `isActive` state of the documents are changed to false.\n\n#### Arguments:\n`query`\ndeletes all documents that match the description of the key-value pair of the queries. If not found, it gives a `failureResponse` in return.\n\n#### Returns:\n Promise.\n\n  If successful then will return an array of deleted `Document Objects` in successResponse.payload\n\n#### Example:\n\n```javascript\ncollection.deleteAll({ 'title' : 'check', 'note' : 'check' })\n  .then((successResponse) =\u003e {\n    // Promise Resolved\n  })\n  .catch((failureResponse) =\u003e {\n    // Promise Rejected\n  });\n```\n","funding_links":[],"categories":["App Development","Libraries"],"sub_categories":["Storage"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feder-ai%2Fcompass-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feder-ai%2Fcompass-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feder-ai%2Fcompass-db/lists"}