{"id":4693,"url":"https://github.com/thewei/react-native-store","last_synced_at":"2025-08-04T01:32:52.168Z","repository":{"id":29855139,"uuid":"33400049","full_name":"thewei/react-native-store","owner":"thewei","description":"A simple database base on react-native AsyncStorage.","archived":true,"fork":false,"pushed_at":"2018-02-16T10:03:29.000Z","size":87,"stargazers_count":569,"open_issues_count":15,"forks_count":74,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-07-19T14:02:39.399Z","etag":null,"topics":["asyncstorage","database","react-native","react-native-store"],"latest_commit_sha":null,"homepage":"https://github.com/thewei/react-native-store","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thewei.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":"2015-04-04T09:08:37.000Z","updated_at":"2025-05-25T00:30:48.000Z","dependencies_parsed_at":"2022-08-29T14:41:59.600Z","dependency_job_id":null,"html_url":"https://github.com/thewei/react-native-store","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/thewei/react-native-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thewei","download_url":"https://codeload.github.com/thewei/react-native-store/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thewei%2Freact-native-store/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268636490,"owners_count":24282098,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asyncstorage","database","react-native","react-native-store"],"created_at":"2024-01-05T20:17:20.469Z","updated_at":"2025-08-04T01:32:51.886Z","avatar_url":"https://github.com/thewei.png","language":"JavaScript","readme":"## react-native-store \n[![Build Status](https://travis-ci.org/thewei/react-native-store.svg?branch=master)](https://travis-ci.org/thewei/react-native-store) \n[![npm version](https://badge.fury.io/js/react-native-store.svg)](http://badge.fury.io/js/react-native-store)\n[![NPM downloads](http://img.shields.io/npm/dm/react-native-store.svg?style=flat-square)](https://npmjs.org/package/react-native-store)\n\nA simple database base on react-native AsyncStorage.\n\n\n### Installation\n```bash\n$ npm install react-native-store --save\n```\n\n***Upgrading from previous version?*** Check for [breaking-changes](breaking-changes.md).\n\n\n### Data anatomy\n```\ndb_store\n   |---model_name\n         |---totalrows (variable)\n         |---autoinc (variable)\n         |---rows (array)\n                |--- _id (number)\n                |--- ....\n\n```\n\n### API\n- **Model( modelName )** : returns a `Model` object\n- **Model.add( data, filter )** : returns a `promise` object\n- **Model.update( data, filter )** : returns a `promise` object\n- **Model.updateById( data, id )** : returns a `promise` object\n- **Model.remove( filter )** : returns a `promise` object\n- **Model.removeById( id )** : returns a `promise` object\n- **Model.find( filter )** : returns a `promise` object\n- **Model.findById( id )** : returns a `promise` object\n- **Model.get( filter )** : returns a `promise` object\n- **Model.destroy()** : returns a `promise` object\n\n### Simple example\n\n```js\nimport Store from 'react-native-store';\n\nconst DB = {\n    'foo': Store.model('foo'),\n    'bar': Store.model('bar')\n}\n\n// somewhere inside react components\n\ncomponentDidMount() {\n    // Return all items\n    DB.foo.find().then(resp =\u003e this.setState({items: resp}));\n}\n\nhandleFilter(itemName) {\n    DB.foo.find({\n        where: {\n            and: [{ foo: { neq: itemName } }, { age: { gte: 5 } }]\n        },\n        order: {\n            age: 'ASC',\n        }\n    }).then(resp =\u003e this.setState({items: resp}));\n}\n\nhandleOnPress() {\n    DB.bar.add({\n        foo: 'foo',\n        bar: 'bar',\n        age: 12\n    });\n}\n\n```\n\n### Advanced Filtering\n\nFiltering adds more advanced logic to queries. This implementation is heavily\nbased off of [LoopBack's implementation](https://docs.strongloop.com/display/public/LB/Querying+data#Queryingdata-Filters).\nHowever, there are some important things that are different/leftout:\n\n- The [include filter](https://docs.strongloop.com/display/public/LB/Include+filter) is not implemented as it is not relevant.\n- The [near and like/nlike](https://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-likeandnlike) operators are not implemented.\n- The [skip filter](https://docs.strongloop.com/display/public/LB/Skip+filter) in LoopBack is the offset filter in this implementation to\n  stay consistent with previous versions.\n\n**Note**: Query operations on object nested within an entry are not perfect.\nFor example, trying to update an entry that looks something like this:\n\n```javascript\n{\n  location: { name: 'place', distance: 'far' }\n}\n```\n\nWith this as the value of a where filter:\n\n```javascript\n{\n  location: { name: 'place' }\n}\n```\n\nWill overwrite the value of `location`, effectively removing the `distance`\nproperty.\nThis occurs similarly with the order and fields filter, as you can only apply\nthe filters to values that are not nested within an object.\n\n\n### Contributing\n- Fork this Repo first\n- Clone your Repo\n- Install dependencies by `$ npm install`\n- Checkout develop branch\n- Feel free to add your features\n- Make sure your features are fully tested\n- Publish your local branch, Open a pull request\n- Enjoy hacking \u003c3\n","funding_links":[],"categories":["Components","动画","组件"],"sub_categories":["Storage","数据存储"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewei%2Freact-native-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthewei%2Freact-native-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthewei%2Freact-native-store/lists"}