CityWebConsultants / Iris

Modular content management and web application framework built with Node.js and MongoDB
http://irisjs.org
Other
9 stars 7 forks source link

Decouple database engine from MongoDB #274

Closed FilipNest closed 8 years ago

FilipNest commented 8 years ago

I've been doing an audit of all the parts of Iris that are directly using MongoDB to see if they can be generalised so that we can slot in a more general database layer that can be used with any database.

I'd love to get nedb support in core as it takes MongoDB syntax and doesn't require any database set up (just an npm install) which would be amazing for small sites. As a larger thing this would allow support for MySQL, PostgreSQL and whatever comes next. Even still supporting MongoDB it makes sense to do as much through an API as we can.

I'm going to go through to swap out every bit of code that calls MongoDB directly (aside from the core db.js and entity stuff which is step 2). Here's what I've found so far. I'm putting this out here so that people can add anything they've got in contributed modules or personal projects.

Obviously entity_edit, entity_delete, entity_create, entity_fetch and db.js as well.

Solution:

Once that's done the only MongoDB specific stuff will be in entity_edit, entity_delete, entity_create, entity_fetch and db.js. Hopefully it shouldn't be too difficult to wrap the final stages of these where the database stuff happens in hooks that depend on which database type is selected in config.

Feel free to add any thoughts. It's a major piece of work but hopefully possible without any breaking changes.