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

mydb-client

v4.0.1

Published

MyDB client component

Downloads

9

Readme

mydb-client

MyDB client component.

Installation

$ npm install mydb-client

Compile with browserify.

Example

var mydb = require('mydb')('mydb.host.com');
mydb.get('/woot/woot');

API

Manager([url|options])

Connects to the mydb server listening on url. If a parameter is not supplied it will connect to window.location Alternatively, an engine.io client options object can be supplied.

Manager#get(url)

Creates a Document by subscribing to the supplied url. Supplying a url is optional, if a vanilla document is desired. See Document#load below.

Document

Each document represents a subscription to a given resource URL.

Document#$manager()

Returns the associated manager.

Document#$sid()

Returns the sebscription id.

Document#$readyState()

  • unloaded: no subscription (default when no url was provided)
  • loading: loading a resource
  • loaded: resource is loaded
  • unloading: subscription is being destroyed

Document#$url()

Returns the url this document is loaded from / loading.

Document#load(url[, fn])

Loads a document from the given URL. If fn is supplied, it's passed to ready.

Document#reload([fn])

Reloads from the URL that was previously given to Document#load. Useful if a given endpoint can return different documents depending on the circumstances. Example: a /me route that returns the currently signed-in user.

Document#ready(fn)

Calls the supplied fn when the resource is loaded. If the resource is already loaded, the function is fired on the next tick.

Document#get(key[, fn])

Returns the value of the given key, which can use dot notation. It throws if the document is not loaded. If fn is supplied, ready is called first, and the value is passed to the callback.

Document#on(key[, op], fn)

Subscribes to changes for the given key.

  • If no operator is supplied, fn gets called upon any operation.
  • Operations that don't change the document are ignored by mongo-query.
  • If an operation is supplied as the second parameter, the first parameter of the event callback will be the value property of the log object. For example, if the operation is a $push, the value that's pushed is the first parameter.
  • Otherwise, the first parameter is always the new value of the given key (after). For example, if the operation is acting on an array, like pushing, pulling or popping, you will still get the reference to the entire array.
  • The second parameter of the event callback is always the log object returned by mongo-query.

Document#upon(key, fn)

Calls ready, then calls fn with the initial value of the given key, and subscribes to subsequent change events for key.

Document#each(key, fn)

Calls ready, then calls fn for each value of the array found under key.

Document#destroy(fn)

Destroys this subscription. fn gets called when the unsubscription for the current id is confirmed.

License

MIT