npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

moonridge-client

v1.0.3

Published

client library for Mongo ORM framework Moonridge

Downloads

58

Readme

Moonridge-client

client library for Mongo remote ORM framework Moonridge.

Install with jspm(for browser) or npm(for node):

npm install moonridge-client

jspm install moonridge-client

Is JSPM really needed?

Moonridge is written in commonJS format(client works in node and browser without much hassle), so you need globally installed jspm to be able to install it with one command. For loading in the browser, you need systemJS(which JSPM installs for you). If you don't have jspm, install it with this command:

npm i jspm -g

As 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.

Basic usage

// ES6 import
import MR from 'moonridge-client'
/// cjs
const MR = require('moonridge-client')

// then just connect to your backend
const backend = MR({url: 'http://localhost:9000'})
// connecting with sync authorization
const backend = MR({url: 'http://localhost:9000', hs: { //hs stands for handshake(is passed to socket.io's connect method)
  query: '[email protected]&password=' + encodeURIComponent(password)
}})

// finally declare which model are you going to use(models are defined with schemas on the backend)
const bookModel = backend.model('book')

Backend instance API

model(string)

synchronously defines a model to be used with the backend

@param {String} name
@returns {Model}

fetchAllModels()

asynchronously gets a list of all models on the backend and then synchronously defines them

@param {String} name
@returns {Model}

authorize(object)

async authorization-use when user connects as anonymous and then gains some priviliges while session is opened

@param {Object} auth object
@returns {Promise} resolved on succesful authorization

deAuthorize()

user logged out/lost priviliges

@returns {Promise} resolved when user was removed from this socket on the server

Model instance API

query()

@returns {QueryChainable} which has same methods as mongoose.js query. When you chain all query
                          conditions, you use exec() to fire the query, Promise is returned

liveQuery([previousLiveQuery])

@param {Object} [previousLQ] useful when we want to modify an existing running LQ, pass it after it is stopped
@returns {QueryChainable} same as query, difference is that executing this QueryChainable won't return
                          promise, but liveQuery object itself

create(object)

@param {Object} toCreate
@returns {Promise} resolved when object is created in the database

update(object)

@param {Object} toUpdate moonridge object
@param {Boolean} resolveWhole if true, it will resolve with whole object instead of just the version
@returns {Promise} resolved when object is saved

Why 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

remove(toRemove)

@param {Object|String} toRemove must have and _id if an object, otherwise we assume the string is the id
@returns {Promise}

addToSet(query, path, item)

@param {Object} query which will be used to find one document to update
@param {String} path
@param {*} item it is highly recommended to use simple values, not objects
@returns {Promise} resolved when object is updated

removeFromSet(query, path, item)

@param {Object} query which will be used to find one document to update
@param {String} path
@param {*} item it is highly recommended to use simple values, not objects
@returns {Promise} resolved when object is updated

on()

@returns {Promise} resolved when subscription is created on the server

off()

@returns {Promise} resolved when subscription is unsubscribed on the server

getSchema()

@returns {Promise} resolved with serialized and deserialized mongoose schema using mongoose-schema-serializer

QueryChainable instance API

Mimics mongoose query api, with some methods dropped. Implemented methods are:

all and box circle comment count distinct elemMatch equals exists find findOne geometry gt gte hint in intersects limit lt lte maxDistance maxScan mod ne near nin nor or ne polygon populate read regex select size skip slice sort where within

js-standard-style