{"id":13804830,"url":"https://github.com/Meteor-Community-Packages/ground-db","last_synced_at":"2025-05-13T18:32:52.645Z","repository":{"id":9637631,"uuid":"11569488","full_name":"Meteor-Community-Packages/ground-db","owner":"Meteor-Community-Packages","description":"GroundDB is a thin layer providing Meteor offline database and methods","archived":false,"fork":false,"pushed_at":"2024-08-07T09:35:14.000Z","size":361,"stargazers_count":569,"open_issues_count":64,"forks_count":77,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-12T23:30:02.007Z","etag":null,"topics":["database","ground","meteor","meteor-offline-database","offline"],"latest_commit_sha":null,"homepage":"https://atmospherejs.com/ground/db","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/Meteor-Community-Packages.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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},"funding":{"github":["storytellercz","jankapunkt"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2013-07-21T23:36:15.000Z","updated_at":"2025-03-04T10:50:50.000Z","dependencies_parsed_at":"2024-11-18T21:41:55.251Z","dependency_job_id":"a4bc06a4-0a6c-4b33-a182-12a73f5d4d8a","html_url":"https://github.com/Meteor-Community-Packages/ground-db","commit_stats":{"total_commits":243,"total_committers":27,"mean_commits":9.0,"dds":"0.20576131687242794","last_synced_commit":"693cebac702e98582f4230023a2570d9c86e0ca0"},"previous_names":["groundmeteor/db"],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fground-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fground-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fground-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fground-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Meteor-Community-Packages","download_url":"https://codeload.github.com/Meteor-Community-Packages/ground-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254003455,"owners_count":21997889,"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","ground","meteor","meteor-offline-database","offline"],"created_at":"2024-08-04T01:00:54.409Z","updated_at":"2025-05-13T18:32:52.246Z","avatar_url":"https://github.com/Meteor-Community-Packages.png","language":"JavaScript","funding_links":["https://github.com/sponsors/storytellercz","https://github.com/sponsors/jankapunkt"],"categories":["Offline"],"sub_categories":[],"readme":"ground:db\n==========\n\n[![Build Status](https://travis-ci.org/GroundMeteor/db.png?branch=grounddb-caching-2016)](https://travis-ci.org/GroundMeteor/db)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\nGroundDB is a fast and thin layer providing Meteor offline database - Taking cloud data to the ground.\n\n## Features\nThis version of GroundDB is a caching only storage - meaning it does not support resuming of method calls/cross tab updates etc. But it's faster and async supporting local storages like:\n* localstorage\n* indexeddb\n* websql\n~* SQLite (on cordova)~\n\n*It's using localforage with some minor modifications - hopefully we can use localForage via npm in the future*\n\n[Notes about migration to GroundDB II](https://github.com/GroundMeteor/db/issues/153#issuecomment-206125703)\n\n## Usage\n\nA pure offline collection\n```js\n  foo = new Ground.Collection('test');\n```\n*Ground.Collection is client-side only and depends on `LocalCollection` for now*\n\n\nGet documents and updates from a Meteor Mongo Collection via DDP\n```js\n  foo = new Ground.Collection('test');\n\n  foo.observeSource(bar.find());\n\n  Meteor.setTimeout(() =\u003e {\n    // Stop observing - keeping all documents as is\n    foo.stopObserver();\n  }, 1000);\n```\n\n## Limiting the stored data\n\nIf you want to clean up the storage and eg. have it match the current subscription, now you can:\n```js\n  foo.keep(bar.find());\n```\n*This will discard all documents not in the subscribed data*\n\n\nLimit the data stored locally\n```js\n  foo.keep(bar.find({}, { limit: 30 }));\n```\n*This will discard all but 30 documents*\n\n\nLimit the data stored locall using multiple cursors\n```js\n  foo.keep(bar.find({ type: 'a' }, { limit: 30 }), bar.find({ type: 'b' }, { limit: 30 }));\n```\n*This will keep at max 60 documents 30 documents of each type \"a\"/\"b\"*\n\n\n## Clear the storage\n```js\n  foo.clear();\n```\n*This will empty the in memory and the local storage*\n\n\n## Need a near backwards compatible solution?\n\nThis example behaves much like the previous version of ground db regarding caching a `Mongo.Collection` - This class inforces a manual clean up. Calling `removeLocalOnly()` will keep only the documents in the `Mongo.Collection`.\n\n```js\nGroundLegacy = {\n  Collection: class GroundLegacy extends Ground.Collection {\n    constructor(collection, options) {\n      if (!(collection instanceof Mongo.Collection)) {\n        throw new Error('GroundLegacy requires a Mongo.Collection');\n      }\n      if (options.cleanupLocalData !== false) {\n        throw new Error('GroundLegacy requires cleanupLocalData to be false');\n      }\n\n      // Create an instance of ground db\n      super(collection._name);\n\n      this.mongoCollection = collection;\n\n      collection.grounddb = this;\n\n      // Observe on the whole collection\n      this.observeSource(collection.find());\n\n      // Store super\n      collection.orgFind = collection.find;\n      collection.orgFindOne = collection.findOne;\n\n      // Overwrite collection finds using the grounded data\n      collection.find = (...args) =\u003e {\n        return this.find(...args);\n      };\n\n      collection.findOne = (...args) =\u003e {\n        return this.findOne(...args);\n      };\n    }\n\n    removeLocalOnly() {\n      // Remove all documents not in current subscription\n      this.keep(this.mongoCollection.orgFind());\n    }\n  },\n};\n```\n\n## More\n\nRead about:\n* [Events](EVENTS.md) in Ground DB\n\n## Contributions\nFeel free to send issues, pull requests all is wellcome\n\nKind regards Morten\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMeteor-Community-Packages%2Fground-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMeteor-Community-Packages%2Fground-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMeteor-Community-Packages%2Fground-db/lists"}