{"id":18799566,"url":"https://github.com/l2silver/mockin","last_synced_at":"2026-01-02T20:30:15.917Z","repository":{"id":57155549,"uuid":"57183341","full_name":"l2silver/mockin","owner":"l2silver","description":"A pseudo frontend relational database","archived":false,"fork":false,"pushed_at":"2016-04-29T02:19:42.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T17:51:24.559Z","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/l2silver.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-04-27T04:28:20.000Z","updated_at":"2016-04-27T04:31:54.000Z","dependencies_parsed_at":"2022-08-26T09:51:06.116Z","dependency_job_id":null,"html_url":"https://github.com/l2silver/mockin","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/l2silver%2Fmockin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Fmockin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Fmockin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Fmockin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/l2silver","download_url":"https://codeload.github.com/l2silver/mockin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239727885,"owners_count":19687263,"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":[],"created_at":"2024-11-07T22:15:46.508Z","updated_at":"2026-01-02T20:30:15.858Z","avatar_url":"https://github.com/l2silver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mockin\nA pseudo-relational frontend database for autonomous global communication  \n**powered by immutablejs*\n\n[![build status](https://travis-ci.org/l2silver/mockin.svg?style=flat-square)](https://travis-ci.org/l2silver/mockin)\n### Example\n```\nconst relationalDatabase = Map({\n    users: Map({\n        1: Map({\n            id: 1,\n            name: 'Joe'\n            friendsTWR: [1]\n        })\n    })\n    friends: Map({\n        1: Map({\n            id: 1,\n            name: 'Tim'\n        })\n    })\n})\n````\nGet a user instance\n````\nconst user = relationalDatabase.getIn(['users', '1'])\n````\nRetrieve relational data\n````\nimport {gex} from 'mockin'\nconst friends = gex(relationalDatabase, 'friends', user)\n````\n### When is this useful?\nWhen multiple objects share information.  \n### How to\nGenerate Database\n````\nimport {wrapMapState} from 'mockin'\n\nconst user = {\n            id: 1,\n            name: 'Joe'\n            friends: [{\n                id: 1,\n                name: 'Tim'\n            }]\n        }\n\nconst frontendRelationalDatabase = wrapMapState(user, ['users', '1'], Map())\n````\nModify Database\n````\nimport {wrapMapState} from 'mockin'\n\nconst users = [{\n            id: 1,\n            name: 'Joe'\n            friends: [{\n                id: 1,\n                name: 'Jim'\n            }]\n        }]\n\nconst newFrontendRelationalDatabase = \nwrapMapState(user, ['users'], frontendRelationalDatabase)\n````\n### How it works\nMockin is powered by objects and arrays of objects that have ids. As mockin processes a regular object, it looks for the id attribute in child objects to know whether or not it should be moved to its own property (akin to tables in databases). If it finds an object with an id inside another object, as with the 'friend' example above, it creates a new property in the original object (the child object name with a TWR suffix) that is an array of ids. It then moves the child object into its own property. The gex function can then be used to recall the relations of an instance, and will by default filter out objects with a non-false deleted_at attribute.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2silver%2Fmockin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl2silver%2Fmockin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2silver%2Fmockin/lists"}