Skip to content

Instantly share code, notes, and snippets.

@jcbombardelli
Created December 29, 2020 15:16
Show Gist options
  • Select an option

  • Save jcbombardelli/667d96467ba57037616f5ab52731719d to your computer and use it in GitHub Desktop.

Select an option

Save jcbombardelli/667d96467ba57037616f5ab52731719d to your computer and use it in GitHub Desktop.
Proof of concept to use mongodb with moongose in atlasdb
const mongoose = require("mongoose");
const run = async () => {
const uri = `mongodb+srv://<username>:<password>@<host>/<database>?retryWrites=true&w=majority`;
await mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true });
const User = mongoose.model("users", new mongoose.Schema({ name: String }));
const result = await User.find({})
console.log(result[0].name)
};
run();
{
"name": "mongoose-atlasdb",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"cross-env": "^7.0.3",
"nodemon": "^2.0.6"
},
"dependencies": {
"mongoose": "^5.11.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment