{"id":22486679,"url":"https://github.com/CapacitorSet/rebridge","last_synced_at":"2025-08-02T19:32:45.041Z","repository":{"id":57349102,"uuid":"63018368","full_name":"CapacitorSet/rebridge","owner":"CapacitorSet","description":"A transparent Javascript interface to Redis.","archived":false,"fork":false,"pushed_at":"2018-02-08T03:18:27.000Z","size":52,"stargazers_count":366,"open_issues_count":1,"forks_count":13,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-01T06:58:11.653Z","etag":null,"topics":["es6","es6-proxies","nodejs","redis","redis-database"],"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/CapacitorSet.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":"2016-07-10T21:03:10.000Z","updated_at":"2024-04-08T12:16:09.000Z","dependencies_parsed_at":"2022-08-29T14:41:05.259Z","dependency_job_id":null,"html_url":"https://github.com/CapacitorSet/rebridge","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapacitorSet%2Frebridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapacitorSet%2Frebridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapacitorSet%2Frebridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapacitorSet%2Frebridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CapacitorSet","download_url":"https://codeload.github.com/CapacitorSet/rebridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228168089,"owners_count":17879693,"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":["es6","es6-proxies","nodejs","redis","redis-database"],"created_at":"2024-12-06T17:15:08.210Z","updated_at":"2024-12-06T17:16:04.449Z","avatar_url":"https://github.com/CapacitorSet.png","language":"JavaScript","readme":"Rebridge\n========\n\n[![npm](https://img.shields.io/npm/v/rebridge.svg?maxAge=2592000)](https://www.npmjs.com/package/rebridge)\n[![Build Status](https://travis-ci.org/CapacitorSet/rebridge.svg?branch=master)](https://travis-ci.org/CapacitorSet/rebridge)\n\nRebridge is a transparent Javascript-Redis bridge. You can use it to create JavaScript objects that are *automatically* synchronized to a Redis database.\n\n## Install\n\n```\nnpm install rebridge\n```\n\n## Usage\n\n### Synchronous, non-blocking usage\n\n```js\nconst Rebridge = require(\"rebridge\");\nconst redis = require(\"redis\");\n\nconst client = redis.createClient();\nconst db = new Rebridge(client, {\n    mode: \"deasync\"\n});\n\ndb.users = [];\ndb.users.push({\n    username: \"johndoe\",\n    email: \"johndoe@domain.com\"\n});\ndb.users.push({\n    username: \"foobar\",\n    email: \"foobar@domain.com\"\n});\ndb.users.push({\n    username: \"CapacitorSet\",\n    email: \"CapacitorSet@users.noreply.github.com\"\n});\nconsole.log(\"Users:\", db.users._value); // Prints the list of users\nconst [me] = db.users.filter(user =\u003e user.username === \"CapacitorSet\");\nconsole.log(\"Me:\", me); // Prints [{username: \"CapacitorSet\", email: \"...\"}]\nclient.quit();\n```\n\n### Asynchronous usage\n\n```js\nconst Rebridge = require(\"rebridge\");\nconst redis = require(\"redis\");\n\nconst client = redis.createClient();\nconst db = new Rebridge(client);\n\ndb.users.set([])\n    .then(() =\u003e Promise.all([\n        db.users.push({\n            username: \"johndoe\",\n            email: \"johndoe@domain.com\"\n        }),\n        db.users.push({\n            username: \"foobar\",\n            email: \"foobar@domain.com\"\n        }),\n        db.users.push({\n            username: \"CapacitorSet\",\n            email: \"CapacitorSet@users.noreply.github.com\"\n        })\n    ]))\n    .then(() =\u003e db.users._promise)\n    .then(arr =\u003e console.log(\"Users:\", arr)) // Prints the list of users\n    .then(() =\u003e db.users.filter(user =\u003e user.username === \"CapacitorSet\"))\n    .then(([me]) =\u003e console.log(\"Me:\", me)) // Prints [{username: \"CapacitorSet\", email: \"...\"}]\n    .then(() =\u003e client.quit())\n    .catch(err =\u003e console.log(\"An error occurred:\", err));\n```\n\n## Requirements\n\nRebridge uses ES6 Proxy objects, so it requires at least Node 6.\n\n## Limitations\n\n* By default, Rebridge objects can't contain functions, circular references, and in general everything for which `x === JSON.parse(JSON.stringify(x))` doesn't hold true. However, you can use a custom serialization function (see below).\n\n* Obviously, you cannot write directly to `db` (i.e. you can't do `var db = Rebridge(); db = {\"name\": \"foo\"}`).\n\n## Custom serialization\n\nBy default, Rebridge serializes to JSON, but you can pass a custom serialization function. For instance, if you wanted to serialize to YAML, you would do something like this:\n\n```js\nconst yaml = require(\"js-yaml\");\nconst db = new Rebridge(client, {\n    serialize: yaml.dump,\n    deserialize: yaml.load\n});\n```\n\n## How it works\n\n`Rebridge()` returns an ES6 Proxy object around `{}`. When you try to read one of its properties, the getter intercepts the call, retrieves and deserializes the result from the database, and returns that instead; the same happens when you write to it.\n\nThe Proxy will forward the native methods and properties transparently, so that the objects it returns should behave the same as native objects; if this is not the case, file an issue on GitHub.\n\nFirst-level objects (eg. `db.foo`) correspond to keys in the Redis database; they are serialized using JSON. When requesting deeper objects (eg. `db.foo.bar.baz`), the first-level object (`db.foo`) is deserialized to a native object, which is then accessed in the standard way.\n","funding_links":[],"categories":["JavaScript","Proxy Resources"],"sub_categories":["Modules"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCapacitorSet%2Frebridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCapacitorSet%2Frebridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCapacitorSet%2Frebridge/lists"}