Skip to content

Commit

Permalink
lint-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Aug 25, 2021
1 parent 26fbb3c commit 0e4263d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions examples/with-mongodb/lib/mongodb.js
@@ -1,32 +1,32 @@
import { MongoClient } from 'mongodb';
import { MongoClient } from 'mongodb'

const uri = process.env.MONGODB_URI;
const uri = process.env.MONGODB_URI
const options = {
useUnifiedTopology: true,
useNewUrlParser: true,
};
}

let client;
let clientPromise;
let client
let clientPromise

if (!process.env.MONGODB_URI) {
throw new Error('Please add your Mongo URI to .env.local');
throw new Error('Please add your Mongo URI to .env.local')
}

if (process.env.NODE_ENV === 'development') {
// In development mode, use a global variable so that the value
// is preserved across module reloads caused by HMR (Hot Module Replacement).
if (!global._mongoClientPromise) {
client = new MongoClient(uri, options);
global._mongoClientPromise = client.connect();
client = new MongoClient(uri, options)
global._mongoClientPromise = client.connect()
}
clientPromise = global._mongoClientPromise;
clientPromise = global._mongoClientPromise
} else {
// In production mode, it's best to not use a global variable.
client = new MongoClient(uri, options);
clientPromise = client.connect();
client = new MongoClient(uri, options)
clientPromise = client.connect()
}

// Export a module-scoped MongoClient promise. By doing this in a
// separate module, the client can be shared across functions.
export default clientPromise;
export default clientPromise
2 changes: 1 addition & 1 deletion examples/with-mongodb/pages/index.js
Expand Up @@ -226,7 +226,7 @@ export async function getServerSideProps(context) {
const client = await clientPromise

// client.db() will be the default database passed in the MONGODB_URI
// You can change the database by calling the client.db() function and specifying a database like:
// You can change the database by calling the client.db() function and specifying a database like:
// const db = client.db("myDatabase");
// Then you can execute queries against your database like so:
// db.find({}) or any of the MongoDB Node Driver commands
Expand Down

0 comments on commit 0e4263d

Please sign in to comment.