-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to connect to gridFS? #51
Labels
Comments
Not directly related to Keep in mind the MongoDB Node.js drivers have updated recently, so this is a bit different to how I used to do it… In import { MongoClient } from 'mongodb'
export let db
export async function connect() {
if (db) return
const client = await MongoClient.connect(process.env.DB_URI)
db = client.db('yourdbname')
} In import { connect } from './db'
// Blah blab…
connect()
.then(() =>
app.listen(process.env.PORT, error => {
if (error) throw error
console.info(
`Serving http://localhost:${process.env.PORT} for ${
process.env.NODE_ENV
}.`
)
})
)
.catch(({ stack }) => console.error(stack)) To use the DB in resolvers: import { db } from './db' It is assumed that the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to implement apollo-upload-server (which is exactly what I'm needing) using gridFS. So I came up to #8 (comment)
But I've some problems how to get connected to the db at all in my express server (do I have to use middleware?), which looks like this:
In my resolver I would like to write the stream:
The text was updated successfully, but these errors were encountered: