My GitHub repo: https://github.com/safiullah7/legan
Branch: redux
I'm following this tutorial: https://tomanagle.medium.com/build-a-rest-api-with-node-js-typescript-mongodb-b6c898d70d61 and I'm unable to connect to my mongodb. Here's my code file where I'm trying to connect with the mongodb:
import config from "config";
import log from "../logger";
function connect() {
const dbUri = config.get("dbUri") as string;
return mongoose
.connect(dbUri, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
log.info("Database connected");
})
.catch((error) => {
log.error("db error", error);
process.exit(1);
});
}
export default connect;
Compiler gives the following error:
No overload matches this call.
Overload 1 of 3, '(uri: string, callback: CallbackWithoutResult): void', gave the following error.
Argument of type '{ useNewUrlParser: boolean; useUnifiedTopology: boolean; }' is not assignable to parameter of type 'CallbackWithoutResult'.
Object literal may only specify known properties, and 'useNewUrlParser' does not exist in type 'CallbackWithoutResult'.
Overload 2 of 3, '(uri: string, options?: ConnectOptions | undefined): Promise<typeof import("mongoose")>', gave the following error.
Argument of type '{ useNewUrlParser: boolean; useUnifiedTopology: boolean; }' is not assignable to parameter of type 'ConnectOptions'.
Object literal may only specify known properties, and 'useNewUrlParser' does not exist in type 'ConnectOptions'.
I'm new to typescript and node/mongoos. Would appreciate your help.