{"id":4694,"url":"https://github.com/darkrishabh/react-native-db-models","last_synced_at":"2025-08-04T01:32:51.933Z","repository":{"id":33698809,"uuid":"37351913","full_name":"darkrishabh/react-native-db-models","owner":"darkrishabh","description":"React native Library for creating Local DB models ","archived":false,"fork":false,"pushed_at":"2018-09-04T21:33:55.000Z","size":31,"stargazers_count":173,"open_issues_count":12,"forks_count":31,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-21T07:46:50.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/darkrishabh.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-06-13T00:58:33.000Z","updated_at":"2024-03-21T10:49:09.000Z","dependencies_parsed_at":"2022-07-29T19:19:19.004Z","dependency_job_id":null,"html_url":"https://github.com/darkrishabh/react-native-db-models","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/darkrishabh/react-native-db-models","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkrishabh%2Freact-native-db-models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkrishabh%2Freact-native-db-models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkrishabh%2Freact-native-db-models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkrishabh%2Freact-native-db-models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darkrishabh","download_url":"https://codeload.github.com/darkrishabh/react-native-db-models/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkrishabh%2Freact-native-db-models/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268636483,"owners_count":24282096,"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":[],"created_at":"2024-01-05T20:17:20.498Z","updated_at":"2025-08-04T01:32:51.687Z","avatar_url":"https://github.com/darkrishabh.png","language":"JavaScript","readme":"![React Native DB Models](http://i58.tinypic.com/2akiqee.png) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdarkrishabh%2Freact-native-db-models.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdarkrishabh%2Freact-native-db-models?ref=badge_shield)\nReact Native DB Models\n===================\n![](https://travis-ci.org/darkrishabh/react-native-db-models.svg?branch=master) ![License](https://img.shields.io/badge/License-MIT-yellowgreen.svg)  [![npm version](https://badge.fury.io/js/react-native-db-models.svg)](http://badge.fury.io/js/react-native-db-models)\n----------\n\n\nThis wrapper is built on top of [React Native Store](https://github.com/thewei/react-native-store) and provides a better and improved Database layer for asynchronous DB transactions.\n\nReact Native DB Models fixes a lot of problems in react native store and also the DB class on top helps to provide more functionality and easy developing options.\n\n[![NPM](https://nodei.co/npm/react-native-db-models.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/react-native-db-models/)\n\n**New Feature added**\nDB Emitter added on all write operations to the models. Which helps you maintain a global storage and re-rendering capabilities for your app.\n\nCheck the new documentation\n\n----------\nUsage\n======================\n\nThe ideal way to use this library is to have a db.js in your applications somewhere. Which will be required.\n\n**DB.js**\n```\nvar RNDBModel = require('react-native-db-models')\n\nvar DB = {\n    \"app\": new RNDBModel.create_db('app'),\n    \"users\": new RNDBModel.create_db('users'),\n}\n\nmodule.exports = DB\n```\nand require it in your code -\n\n```\nvar React = require('react-native');\nvar DB = require('./db.js');\n// DB Emitter Initialized\n\nvar DBEvents = require('react-native-db-models').DBEvents\nvar {\n    AppRegistry,\n    StyleSheet,\n    Text,\n    View,\n    Image\n    } = React;\n    \n// Only \"all\" event emitter is available\n\nDBEvents.on(\"all\", function(){\n\tconsole.log(\"Database changed\");\n})\n\nvar App = React.createClass({\n\tget_users: function(){\n\t\tDB.users.get_all(function(result){\n\t\t\tconsole.log(result);\n\t\t})\n\t},\n\trender: function(){\n\t\treturn (\n\t\t\u003cView\u003e\n\t\t\t\u003cText onPress={this.get_users}\u003e Hello \u003c/Text\u003e\n\t\t\u003c/View\u003e\n\t\t);\n\t}\n});\n```\nAll methods are async and therefore require a callback method.\n======================\nYou can check all the returned data from the callback. The returned data is more than expected so modify it as per your needs.\n\n----------\n**get**\n\n\u003e **get(query_data, callback)**\n\u003e query_data: The data to be matched. (eg. {name: \"John Doe\"})\n\nExample\n```\nDB.users.get({first_name: \"Rishabh\"}, function(results){\n\tconsole.log(results);\n})\n```\n----------\n**get_id**\n\n\u003e **get_id(id, callback)**\n\u003e id: ID of the object to be fetched.\n\nExample\n```\nDB.users.get_id(10, function(results){\n\tconsole.log(results);\n})\n```\n\n----------\n**get_all**\n\n\u003e **get_all(callback)**\n\u003e Gets the complete table for you.\n\nExample\n\n```\nDB.users.get_all(function(result){\n\t\t\tconsole.log(result);\n\t\t})\n```\n\n----------\n**remove**\n\n\u003e **remove(query_data, callback)**\n\u003e query_data: The data to be matched. (eg. {name: \"John Doe\"})\n\nExample\n```\nDB.users.remove({first_name: \"Rishabh\"}, function(removed_data){\n\tconsole.log(removed_data);\n})\n```\n\n----------\n**remove_id**\n\n\u003e **remove_id(id, callback)**\n\u003e id: ID of the object to be deleted.\n\nExample\n```\nDB.users.remove({first_name: \"Rishabh\"}, function(removed_data){\n\tconsole.log(removed_data);\n})\n```\n----------\n**add**\n\n\u003e **add(data, callback)**\n\u003e data: The data to be added. (eg. {name: \"John Doe\", age: 56})\n\nExample\n```\nDB.users.add({first_name: \"Rishabh\", age: 25}, function(added_data){\n\tconsole.log(added_data); \n})\n```\n\n\n----------\n**update**\n\n\u003e **update(query_data, new_data, callback)**\n\u003e query_data: The data to be matched. (eg. {name: \"John Doe\"})\n\u003e new_data: The data to be updated. (eg. {age: 12})\n\nExample\n```\nDB.users.update({first_name: \"Rishabh\"}, {age: 25}, function(updated_table){\n\tconsole.log(updated_table);\n})\n```\n\n----------\n**update_id**\n\n\u003e **update_id(id, new_data, callback)**\n\u003e id: The id of the data to be matched.\n\u003e new_data: The data to be updated. (eg. {name: \"Ken\"})\n\nExample\n```\nDB.users.update_id(3, {name: \"Ken\", age: 12}, function(updated_table){\n\tconsole.log(updated_table);\n})\n```\n----------\n**erase_db**\n\n\u003e **erase_db(callback)**\n\u003e Erases the complete table.\n\nExample\n```\nDB.users.erase_db(function(removed_data){\n\tconsole.log(removed_data);\n})\n```\n \n \n *More methods and features are gonna be added soon. Such as update, replace, constraints*\n\n----------\n\n\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdarkrishabh%2Freact-native-db-models.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdarkrishabh%2Freact-native-db-models?ref=badge_large)","funding_links":[],"categories":["Components"],"sub_categories":["Storage"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkrishabh%2Freact-native-db-models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkrishabh%2Freact-native-db-models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkrishabh%2Freact-native-db-models/lists"}