Building an extra layer of data access on top of mongoose

For my application, node.js

I use it mongodb

as a database. Also I prefer to use mongoose.js

on top of it. My question is:

is it possible to build an additional layer on top mongoose.js

to access the data ?. As for CRUD operations

?

as a set of common functions that does exactly what it does mongoose

and restricts coding from direct request mongoose

and can help at a later stage when we change the db or mongoose

. I'm asking this because I can't figure out how effective it would be at a later stage, but it seems annoying now. Please suggest.

+3


source to share


1 answer


It's hard to answer definitively, but I tend to have this "extra" layer for easier checking. For example. it's easier to test classes / files in isolation. Also useful if you want to refactor another data store at some point.



+3


source







All Articles