{"id":15296050,"url":"https://github.com/capaj/moonridge-client","last_synced_at":"2025-07-27T10:33:16.546Z","repository":{"id":57302743,"uuid":"29439501","full_name":"capaj/moonridge-client","owner":"capaj","description":"client library for Mongo ORM framework Moonridge","archived":false,"fork":false,"pushed_at":"2016-06-19T08:30:35.000Z","size":113,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-15T01:21:16.705Z","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/capaj.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-01-18T20:17:33.000Z","updated_at":"2019-08-13T16:00:34.000Z","dependencies_parsed_at":"2022-09-20T17:43:36.084Z","dependency_job_id":null,"html_url":"https://github.com/capaj/moonridge-client","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fmoonridge-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fmoonridge-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fmoonridge-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capaj%2Fmoonridge-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/capaj","download_url":"https://codeload.github.com/capaj/moonridge-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227798745,"owners_count":17821546,"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-09-30T18:09:04.239Z","updated_at":"2024-12-02T20:28:57.184Z","avatar_url":"https://github.com/capaj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Moonridge-client\nclient library for Mongo remote ORM framework [Moonridge](https://github.com/capaj/Moonridge).\n\nInstall with jspm(for browser) or npm(for node):\n\n```\nnpm install moonridge-client\n\njspm install moonridge-client\n```\n### Is JSPM really needed?\n\nMoonridge is written in commonJS format(client works in node and browser without much hassle), so you need globally installed [jspm](https://github.com/jspm/jspm-cli) to be able to install it with one command. For loading in the browser, you need [systemJS](https://github.com/systemjs/systemjs)(which JSPM installs for you).\nIf you don't have jspm, install it with this command:\n\n    npm i jspm -g\n\nAs it works in node, it should be possible to run in browserify/webpack as well, but I don't guarantee it. JSPM might also be able to make you a bundle of all scripts needed. This bundle can then be used as regular script file with a script tag. Theoretically.\n\n## Basic usage\n\n```javascript\n// ES6 import\nimport MR from 'moonridge-client'\n/// cjs\nconst MR = require('moonridge-client')\n\n// then just connect to your backend\nconst backend = MR({url: 'http://localhost:9000'})\n// connecting with sync authorization\nconst backend = MR({url: 'http://localhost:9000', hs: { //hs stands for handshake(is passed to socket.io's connect method)\n  query: 'email=john@mail.com\u0026password=' + encodeURIComponent(password)\n}})\n\n// finally declare which model are you going to use(models are defined with schemas on the backend)\nconst bookModel = backend.model('book')\n```\n\n### Backend instance API\n#### model(string)\nsynchronously defines a model to be used with the backend\n```\n@param {String} name\n@returns {Model}\n```\n#### fetchAllModels()\nasynchronously gets a list of all models on the backend and then synchronously defines them\n```\n@param {String} name\n@returns {Model}\n```\n#### authorize(object)\nasync authorization-use when user connects as anonymous and then gains some priviliges while session is opened\n```\n@param {Object} auth object\n@returns {Promise} resolved on succesful authorization\n```\n#### deAuthorize()\nuser logged out/lost priviliges\n```\n@returns {Promise} resolved when user was removed from this socket on the server\n```\n\n### Model instance API\n#### query()\n```\n@returns {QueryChainable} which has same methods as mongoose.js query. When you chain all query\n                          conditions, you use exec() to fire the query, Promise is returned\n```\n#### liveQuery([previousLiveQuery])\n```\n@param {Object} [previousLQ] useful when we want to modify an existing running LQ, pass it after it is stopped\n@returns {QueryChainable} same as query, difference is that executing this QueryChainable won't return\n                          promise, but liveQuery object itself\n```\n#### create(object)\n```\n@param {Object} toCreate\n@returns {Promise} resolved when object is created in the database\n```\n#### update(object)\n```\n@param {Object} toUpdate moonridge object\n@param {Boolean} resolveWhole if true, it will resolve with whole object instead of just the version\n@returns {Promise} resolved when object is saved\n```\nWhy not return whoole object by default? Because it would waste bandwith. If you need to display latest version of a document, it is preferable to use liveQuery().findOne({_id: id}), instead of manually updating your copy\n#### remove(toRemove)\n```\n@param {Object|String} toRemove must have and _id if an object, otherwise we assume the string is the id\n@returns {Promise}\n```\n#### addToSet(query, path, item)\n```\n@param {Object} query which will be used to find one document to update\n@param {String} path\n@param {*} item it is highly recommended to use simple values, not objects\n@returns {Promise} resolved when object is updated\n```\n#### removeFromSet(query, path, item)\n```\n@param {Object} query which will be used to find one document to update\n@param {String} path\n@param {*} item it is highly recommended to use simple values, not objects\n@returns {Promise} resolved when object is updated\n```\n#### on()\n```\n@returns {Promise} resolved when subscription is created on the server\n```\n#### off()\n```\n@returns {Promise} resolved when subscription is unsubscribed on the server\n```\n#### getSchema()\n```\n@returns {Promise} resolved with serialized and deserialized mongoose schema using mongoose-schema-serializer\n```\n\n### QueryChainable instance API\nMimics mongoose query api, with some methods dropped. Implemented methods are:\n\n[all](http://mongoosejs.com/docs/api.html#query_Query-all)\n[and](http://mongoosejs.com/docs/api.html#query_Query-and)\n[box](http://mongoosejs.com/docs/api.html#query_Query-box)\n[circle](http://mongoosejs.com/docs/api.html#query_Query-circle)\n[comment](http://mongoosejs.com/docs/api.html#query_Query-comment)\n[count](http://mongoosejs.com/docs/api.html#query_Query-count)\n[distinct](http://mongoosejs.com/docs/api.html#query_Query-distinct)\n[elemMatch](http://mongoosejs.com/docs/api.html#query_Query-elemMatch)\n[equals](http://mongoosejs.com/docs/api.html#query_Query-equals)\n[exists](http://mongoosejs.com/docs/api.html#query_Query-exists)\n[find](http://mongoosejs.com/docs/api.html#query_Query-find)\n[findOne](http://mongoosejs.com/docs/api.html#query_Query-findOne)\n[geometry](http://mongoosejs.com/docs/api.html#query_Query-geometry)\n[gt](http://mongoosejs.com/docs/api.html#query_Query-gt)\n[gte](http://mongoosejs.com/docs/api.html#query_Query-gte)\n[hint](http://mongoosejs.com/docs/api.html#query_Query-hint)\n[in](http://mongoosejs.com/docs/api.html#query_Query-in)\n[intersects](http://mongoosejs.com/docs/api.html#query_Query-intersects)\n[limit](http://mongoosejs.com/docs/api.html#query_Query-limit)\n[lt](http://mongoosejs.com/docs/api.html#query_Query-lt)\n[lte](http://mongoosejs.com/docs/api.html#query_Query-lte)\n[maxDistance](http://mongoosejs.com/docs/api.html#query_Query-maxDistance)\n[maxScan](http://mongoosejs.com/docs/api.html#query_Query-maxScan)\n[mod](http://mongoosejs.com/docs/api.html#query_Query-mod)\n[ne](http://mongoosejs.com/docs/api.html#query_Query-ne)\n[near](http://mongoosejs.com/docs/api.html#query_Query-near)\n[nin](http://mongoosejs.com/docs/api.html#query_Query-nin)\n[nor](http://mongoosejs.com/docs/api.html#query_Query-nor)\n[or](http://mongoosejs.com/docs/api.html#query_Query-or)\n[ne](http://mongoosejs.com/docs/api.html#query_Query-ne)\n[polygon](http://mongoosejs.com/docs/api.html#query_Query-polygon)\n[populate](http://mongoosejs.com/docs/api.html#query_Query-populate)\n[read](http://mongoosejs.com/docs/api.html#query_Query-read)\n[regex](http://mongoosejs.com/docs/api.html#query_Query-regex)\n[select](http://mongoosejs.com/docs/api.html#query_Query-select)\n[size](http://mongoosejs.com/docs/api.html#query_Query-size)\n[skip](http://mongoosejs.com/docs/api.html#query_Query-skip)\n[slice](http://mongoosejs.com/docs/api.html#query_Query-slice)\n[sort](http://mongoosejs.com/docs/api.html#query_Query-sort)\n[where](http://mongoosejs.com/docs/api.html#query_Query-where)\n[within](http://mongoosejs.com/docs/api.html#query_Query-within)\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapaj%2Fmoonridge-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapaj%2Fmoonridge-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapaj%2Fmoonridge-client/lists"}