{"id":24087988,"url":"https://github.com/konsultaner/jsonodm","last_synced_at":"2025-05-05T21:41:06.387Z","repository":{"id":28467703,"uuid":"31983550","full_name":"konsultaner/jsonOdm","owner":"konsultaner","description":"A JSON ODM (object document mapper) for JavaScript to use on the server or in the browser.","archived":false,"fork":false,"pushed_at":"2023-03-08T13:21:37.000Z","size":2348,"stargazers_count":101,"open_issues_count":1,"forks_count":12,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-23T03:37:55.293Z","etag":null,"topics":["database","document-mapper","javascript","json","odm"],"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/konsultaner.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-03-10T21:46:54.000Z","updated_at":"2025-03-08T20:59:06.000Z","dependencies_parsed_at":"2024-01-03T05:42:23.421Z","dependency_job_id":"3594e2cd-2c73-4345-956b-b6bda7fd2162","html_url":"https://github.com/konsultaner/jsonOdm","commit_stats":{"total_commits":130,"total_committers":2,"mean_commits":65.0,"dds":0.01538461538461533,"last_synced_commit":"6853a6393ce041280d3c3fa982859bc728877c8f"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsultaner%2FjsonOdm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsultaner%2FjsonOdm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsultaner%2FjsonOdm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konsultaner%2FjsonOdm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konsultaner","download_url":"https://codeload.github.com/konsultaner/jsonOdm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252581812,"owners_count":21771572,"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","document-mapper","javascript","json","odm"],"created_at":"2025-01-10T03:56:52.787Z","updated_at":"2025-05-05T21:41:06.365Z","avatar_url":"https://github.com/konsultaner.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/konsultaner/jsonOdm.svg?branch=master)](https://travis-ci.org/konsultaner/jsonOdm)\n[![Code Climate](https://codeclimate.com/github/konsultaner/jsonOdm/badges/gpa.svg)](https://codeclimate.com/github/konsultaner/jsonOdm)\n[![Test Coverage](https://codeclimate.com/github/konsultaner/jsonOdm/badges/coverage.svg)](https://codeclimate.com/github/konsultaner/jsonOdm/coverage)\n[![npm](https://img.shields.io/npm/dm/json-odm.svg)](https://www.npmjs.com/package/json-odm)\n[![npm](https://img.shields.io/npm/v/json-odm.svg)](https://www.npmjs.com/package/json-odm)\n[![npm](https://img.shields.io/npm/l/json-odm.svg)](https://www.npmjs.com/package/json-odm)\n[![GitHub stars](https://img.shields.io/github/stars/konsultaner/jsonOdm.svg)](https://github.com/konsultaner/jsonOdm/stargazers)\n[![GitHub issues](https://img.shields.io/github/issues/konsultaner/jsonOdm.svg)](https://github.com/konsultaner/jsonOdm/issues)\n\nJSON ODM\n========\nby [Konsultaner](http://www.konsultaner.de), Richard Burkhardt\n-------------\n\nThis Project aims to be provide a json object document mapper.  \n**Why would I need this?**  \nThere are many cases where you do not want to have the server query your data. You may also see this mapper as a fancy way to filter your data or prepare a view model.\nThe original use case was an [ionic](http://ionicframework.com) app that was not interactive so providing a server backend was not needed, but structuring my data\ninto joinable collections seemed very helpful.\n\nAnd if you can use a server you may consider our new [WebSocket server project \"connectanum\"](http://www.connectanum.com) for Publish/Subscribe and RPC communication \n  \nIf you like the project please support it with a star here on [GitHub](https://github.com/konsultaner/jsonOdm)  \n  \nIf commercial support is needed please [contact me](mailto:burkhardt@konsultaner.de).  \n\nDocs\n----\nYou can find the [documentation here](https://rawgit.com/konsultaner/jsonOdm/master/docs/gen/0.2/index.html) or compiled to the folder [/docs/gen/*](https://github.com/konsultaner/jsonOdm/blob/master/docs/gen/index.html).\n\nRoad map\n----\n\n- [ ] Implement query methods from [mongo db](http://docs.mongodb.org/manual/reference/operator/query/)\n    - [x] Comparison 100%\n        - [x] $eq\n        - [x] $gt\n        - [x] $gte\n        - [x] $lt\n        - [x] $lte\n        - [x] $ne\n        - [x] $in\n        - [x] $nin\n    - [x] Logical 100%\n        - [x] $or\n        - [x] $and\n        - [x] $not(= $nand as alias)\n        - [x] $nor\n    - [x] Element 100% (+ $isNull, for is null or undefined)\n        - [x] $exists\n        - [x] $type\n    - [x] Evaluation 100%\n        - [x] $mod\n        - [x] $regex\n        - [x] $text\n        - [x] $where\n    - [x] Geospatial 50% (maybe have a hard and a soft check -\u003e performance)\n        - [x] $geoWithin\n        - [x] $geoIntersects\n        - [ ] $near\n        - [ ] $nearSphere\n    - [ ] Array 0% i may not implement the first two\n        - [ ] $all\n        - [ ] $elementMatch\n        - [ ] $size\n    - [ ] Aggregation\n        - [ ] Pipeline 30% ($limit and $skip is implemented as $result(skip,limit))\n            - [x] $project\n            - [ ] $match\n            - [ ] $redact\n            - [x] $limit\n            - [x] $skip\n            - [ ] $unwind\n            - [ ] $sort\n            - [ ] $geoNear\n            - [ ] $out\n        - [ ] Grouping 70% ($count is used to count the results)\n            - [x] $group\n            - [x] $count\n            - [x] $sum\n            - [x] $avg\n            - [ ] $first\n            - [ ] $last\n            - [x] $min\n            - [x] $max\n            - [x] $push\n            - [ ] $addToSet\n        - [ ] Operators 20% ($mod is renamed $modulo, because Evaluation has a $mod)\n            - [ ] Boolean\n            - [ ] Set\n            - [ ] Comparison\n            - [x] Arithmetic\n            - [x] String\n            - [ ] Array\n            - [ ] Date\n            - [ ] Conditional\n            - [ ] Variable\n            - [ ] Grouping\n- [ ] Support Promise/A+ sources for the odm.addSource\n- [ ] Full CRUD support\n- [ ] Aggregation\n\nInstall from NPM-Package\n---------------------\n\n```bash\nnpm install json-odm\n```\n\nBuild and run tests, both minified and unminified\n-------------------------------------------------\n\nSince [PhantomJs has been archived](https://github.com/ariya/phantomjs/issues/15344), jsonOdm needed to switch to chrome \nheadless for its test. To run tests have Chrome installed!\n\n```bash\nnpm install json-odm\ncd npm_modules/json-odm/\nnpm install\ngulp\n```\n\nBrowser Support\n---------------\nUnit test ran successfully under Chrome,iOS7+,IE9+,Firefox,Android 4.4.2+  \nTo be tested: Safari on OSX, IE8(test driver does not run in IE \u003c 9 so it will be hard to test)\n\nExample\n------\nThis is only a basic example. Find a lot more in the [docs](https://rawgit.com/konsultaner/jsonOdm/master/docs/gen/index.html), i.e. how to use [$geoWithin](https://rawgit.com/konsultaner/jsonOdm/master/docs/gen/jsonOdm.Query.html#__geoWithin__anchor)\n```html\n\u003c!-- add minified version from https://github.com/konsultaner/jsonOdm/tree/master/bin to the html head --\u003e\n\u003cscript type=\"text/javascript\" src=\"js/json.odm.min.js\"\u003e\u003c/script\u003e\n```\n\n```javascript\n// initialize The mapper\nvar odm = new jsonOdm();\n// add a source to the mapper\nodm.addSource('people',{\n   \"Person\" : [\n       {\"id\":1,\"name\":\"Richi\",jobId:1,hobbyIds:[1,3,4]},\n       {\"id\":2,\"name\":\"Dave\",jobId:2,hobbyIds:[2,4]},\n       {\"id\":3,\"name\":\"Tom\",jobId:3,hobbyIds:[3,5]},\n       {\"id\":4,\"name\":\"Lisa\",jobId:4,hobbyIds:[1,2,3]},\n       {\"id\":5,\"name\":\"Hanni\",jobId:3,hobbyIds:[1,5]},\n       {\"id\":6,\"name\":\"Selma\",jobId:3,hobbyIds:[1,4]},\n       {\"id\":7,\"name\":\"Ralf\",jobId:1,hobbyIds:[4,3]}\n   ],\n   \"Jobs\" : [\n       {\"id\":1,\"name\":\"plumber\"},\n       {\"id\":2,\"name\":\"programmer\"},\n       {\"id\":3,\"name\":\"chef\"},\n       {\"id\":4,\"name\":\"hairdresser\"}\n   ],\n   \"Hobbies\" : [\n       {\"id\":1,\"name\":\"swimming\"},\n       {\"id\":2,\"name\":\"cycling\"},\n       {\"id\":3,\"name\":\"fishing\"},\n       {\"id\":4,\"name\":\"coding\"},\n       {\"id\":5,\"name\":\"dancing\"}\n   ]\n},true);\n// instantiate a collection object\nvar people = new odm.Collection('Person');\npeople.$hasOne(\"jobId\",\"id\",\"Jobs\",\"job\");\npeople.$hasMany(\"hobbyIds\",\"id\",\"Hobbies\",\"hobbies\");\n\nvar q = people.$query();\n// get all hairdresser and plumber\nvar hairdresser = q.$or(\n    q.$branch(\"jobId\").$eq(1),\n    q.$branch(\"jobId\").$eq(4)\n).$all();\n\n// get all but hairdressers and plumbers\nvar hairdresser = q.$and(\n   q.$branch(\"jobId\").$ne(1),\n   q.$branch(\"jobId\").$ne(4)\n).$all();\n\n// delete all plumbers\nq.$branch(\"job\",\"name\").$eq(\"plumber\").$delete();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsultaner%2Fjsonodm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonsultaner%2Fjsonodm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonsultaner%2Fjsonodm/lists"}