Skip to content

Instantly share code, notes, and snippets.

@EssenceOfChaos
Created September 28, 2017 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EssenceOfChaos/448c9ee552dd3fc57134ad9eb47f7fbd to your computer and use it in GitHub Desktop.
Save EssenceOfChaos/448c9ee552dd3fc57134ad9eb47f7fbd to your computer and use it in GitHub Desktop.
testing the stitch connection
const stitch = require("mongodb-stitch")
//'rating-iyxzl' is the app name given by stitch
const client = new stitch.StitchClient('rating-iyxzl');
// the db name 'tour-of-heroes' was provided by me
const db = client.service('mongodb', 'mongodb-atlas').db('tour-of-heroes');
client.login().then(() =>
db.collection('ratings').updateOne({ owner_id: client.authedId() }, { $set: { number: 42 } }, { upsert: true })
).then(() =>
db.collection('ratings').find({ owner_id: client.authedId() })
).then(docs => {
console.log("Found docs", docs)
console.log("[MongoDB Stitch] Connected to Stitch")
}).catch(err => {
console.error(err)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment