ms

mongodb-stitch

[![Join the chat at https://gitter.im/mongodb/stitch](https://badges.gitter.im/mongodb/stitch.svg)](https://gitter.im/mongodb/stitch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Showing:

Popularity

Downloads/wk

322

Maintenance

No Maintenance Data Available

Package

Dependencies

7

Size (min+gzip)

44.8KB

License

Apache-2.0

Type Definitions

Tree-Shakeable

No?

Categories

Deprecated!
The browser SDK has moved to mongodb-stitch-browser-sdk, and the Node.js SDK has moved to mongodb-stitch-server-sdk

Readme

mongodb-stitch

Join the chat at https://gitter.im/mongodb/stitch

MongoDB Stitch Users - Google Group

MongoDB Stitch Announcements - Google Group

The original source is located in src/. To transpile to pure JS, run npm run build which places the output into dist/.

Documentation

Usage

Construct a simple app-wide client

import { StitchClientFactory } from 'mongodb-stitch';
let appId = 'sample-app-ovmyj';
let stitchClientPromise = StitchClientFactory.create(appId);

The StitchClient only needs to be resolved once from StitchClientFactory.create() and it can be used for the lifetime of an application.

Authenticate anonymously

stitchClientPromise.then(stitchClient => stitchClient.login())
  .then(() => console.log('logged in as: ' + stitchClient.authedId()))
  .catch(e => console.log('error: ', e));

Access MongoDB APIs

stitchClientPromise.then(stitchClient => {
  let db = stitchClient.service('mongodb', 'mongodb1').db('app-ovmyj'); // mdb1 is the name of the mongodb service registered with the app.
  let itemsCollection = db.collection('items');

  // CRUD operations:
  const userId = stitchClient.authedId();
  return itemsCollection.insertMany(
    [ 
      { owner_id: userId, x: 'item1' }, 
      { owner_id: userId, x: 'item2' }, 
      { owner_id: userId, x: 'item3' } 
    ]
  );
}).then(result => console.log('success: ', result))
  .catch(e => console.log('error: ', e));

Execute a function

stitchClientPromise.then(stitchClient => 
  stitchClient.executeFunction('myFunc', 1, 'arg2', {arg3: true})
).then(result => console.log('success: ', result))
  .catch(e => console.log('error: ', e));

Execute a service function

stitchClientPromise.then(stitchClient =>
  stitchClient.executeServiceFunction('http1', 'get', {url: 'https://domain.org'})
).then(result => console.log('success: ', result))
  .catch(e => console.log('error: ', e));

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial