Socket
Book a DemoInstallSign in
Socket

limbo-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

limbo-client

Factory/Loader of mongoose

latest
Source
npmnpm
Version
0.6.0
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

limbo-client

RPC Client for limbo

Usage

serveice/limbo.js

// run the script only once
var limbo = require('limbo-client')
var db = limbo.use('databaseName')
db.connect({
  url: 'tcp://localhost:5700'
}, function (err) {
  if (err) throw new Error(err)
})

some/api.js

var db = limbo.use('databaseName')
  db.user.findOne({}, function (err, one) {
  ...
})

API

use(dbName)

return a database provider instance. once the provider connected, it can be used anywhere.

provider.connect(options, callback)

connect a remote RPC limbo server and fetch model and methods from server.

NOTICE: since the connect would only be done once, models and methods would only be fetched once. That means if the server changed schemas and restart, client would not fetch again.

NOTICE2: tls Options only for limbo#dev and it's recommended.

  • options:
    • url(String): (tcp|tls)://[host]:[port], e.g. tcp://localhost:5700
    • tls(Object): if url protocal is tls, options should has tls. also see tls Options
  • callback(Function): callback when connected or fail

provider[model]

return the remote rpc model of limbo. It is more like mongoose model.

Notice1: since it is a remote model, model.find is a simulated method to fetch the document. and the document IS NOT a real document, it is toJSONed.

So you CAN NOT use document as a mongoose document to call something like save method. Use db.model.update() instead. To be honest, it is safer to call update than save for knowing what you have done to the document.

Licence

MIT

Keywords

mongoose

FAQs

Package last updated on 25 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts