Skip to content

Instantly share code, notes, and snippets.

@PonomareVlad
Created November 29, 2023 20:52
Show Gist options
  • Save PonomareVlad/022b247bd39306853f87b7c6a13b48aa to your computer and use it in GitHub Desktop.
Save PonomareVlad/022b247bd39306853f87b7c6a13b48aa to your computer and use it in GitHub Desktop.
MongoDB collections exports
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();
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