Created
November 29, 2023 20:52
-
-
Save PonomareVlad/022b247bd39306853f87b7c6a13b48aa to your computer and use it in GitHub Desktop.
MongoDB collections exports
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
import db from "./mongo.mjs"; | |
db.users.find(); | |
db.posts.find(); | |
db.gifts.find(); | |
/* OR */ | |
import {users, posts, gifts} from "./mongo.mjs"; | |
users.find(); | |
posts.find(); | |
gifts.find(); |
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
import {MongoClient} from "mongodb"; | |
const {MONGODB_URI} = process.env; | |
const client = await MongoClient.connect(MONGODB_URI); | |
const db = client.db("Telegram"); | |
export const users = db.collection("users"); | |
export const posts = db.collection("posts"); | |
export const gifts = db.collection("gifts"); | |
export default {users, posts, gifts}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment