Created
December 29, 2020 15:16
-
-
Save jcbombardelli/667d96467ba57037616f5ab52731719d to your computer and use it in GitHub Desktop.
Proof of concept to use mongodb with moongose in atlasdb
This file contains hidden or 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 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(); |
This file contains hidden or 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
| { | |
| "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