Created
September 28, 2017 22:54
-
-
Save EssenceOfChaos/448c9ee552dd3fc57134ad9eb47f7fbd to your computer and use it in GitHub Desktop.
testing the stitch connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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