luisgo
luisgo

Reputation: 2465

Specify a local mongodb data file for specific Node.js application

My apologies if this has been asked before but I haven't been able to find the answer.

I have a small project written in express.js (node.js) that uses a local sqlite data file. I want to switch to mongodb but would like to keep the data file within the project directory. Is that possible with mongodb and, if so, can anyone offer any guidance?

Thank you,

Luis

Upvotes: 1

Views: 114

Answers (2)

ksimons
ksimons

Reputation: 3826

It's certainly possible. In your mongod.conf file, simply point the dbpath property at whatever directory you'd like

dbpath = /path/to/your/project

Keep in mind that unlike sqlite, MongoDB creates a number of files. And that number changes as your data changes.

Upvotes: 1

Peter Lyons
Peter Lyons

Reputation: 146084

mongod --dbpath myappdir/mongo

Upvotes: 2

Related Questions