@ifit/mongoose-dao
    TypeScript icon, indicating that this package has built-in type declarations

    2.2.0 • Public • Published

    Build Status codecov

    Purpose

    Mongo helper methods for working with data in a DAO or repository pattern. As well as some required misc helper methods for interacting with mongo.

    DAO/Repository Pattern

    The primary purpose of this is to abstract the interaction with the Database. This has the following benefits:

    • Easier to mock and DI throughout the app
    • Doesn't depend so heavily throughout the app on setting up Mockgoose
    • Wraps all response objects in a proper class
    • Avoids the messy nature of Mongoose statics/methods

    Helpers

    The pattern requires the following on Mongo objects:

    • There is a createdAt and updatedAt field
    • That _id is auto converted to id when toObject() is called
    • That __v is removed when toObject() is called

    To do that, there is a helper method that sets those up. Simply call initMongoCleanAndTimestamp() in the models of the app.

    Examples

    See the sample folder. The file/folder structure and files should be all that you need to get started.

    Contributing

    See CONTRIBUTING.md

    Installing dependencies for the project locally

    • yarn install - Installs all the dependencies
    • yarn prepare - Installs in the peer dependencies for local development

    Scripts

    • clean - Cleans the project build directories
    • build - Cleans and compiles the code to the out dir
    • watch - Builds and watches for changes, on changes builds
    • lint - Runs TypeScript linting
    • test - Runs all the test marked with .test.ts
    • coverage - Runs code coverage, generates an HTML report, and opens it in the browser
    • prepare - Installs local peer dependencies

    Keywords

    none

    Install

    npm i @ifit/mongoose-dao

    DownloadsWeekly Downloads

    18

    Version

    2.2.0

    License

    ISC

    Unpacked Size

    54.6 kB

    Total Files

    41

    Last publish

    Collaborators

    • leyla.alonso
    • awwifit
    • spencer.wadsworth
    • sean.nelson
    • marcelorubini
    • rexn
    • nikorablin
    • peter.ifit.com
    • zachhawkes
    • albertot
    • jandersen
    • junchaoz
    • mario495
    • aaronl
    • johnmifit
    • cbrammer
    • thomaswilliams
    • boo-urns
    • michelle.bowser
    • robertleeplummerjr
    • mojojoejoe
    • hayden289
    • marshallrogers
    • ifitshared
    • rkaneda9
    • morganrramsey
    • jayullman
    • clodpated
    • joekuhn
    • derekthedev
    • caritochoa
    • jtuesday
    • bdoney
    • brycebifit
    • perkyguy
    • mark-archer
    • tdfacer
    • spencer.simmons0225
    • joshifit
    • yodafred
    • jrgould
    • jonb-ifit
    • sm-npm
    • weaster-ifit
    • cadec
    • wesleyf
    • donj
    • jamilammar
    • phild
    • dawsontoth
    • ifit-colin
    • edh57
    • jeffbernst
    • michaelh-ifit
    • jthurman
    • hayesashbyifit
    • matthewpthomas
    • 32graham
    • justinwifit
    • jcalmonte
    • bikersteve
    • jayswansonce
    • michaelh3-ifit
    • lejlapri
    • barr-code
    • terrellf
    • samc-ifit
    • taylort
    • jeffy-ifit
    • bennyk-ifit
    • gaartok
    • johnc-ifit
    • jessefit
    • edvio4
    • xbladex
    • clarcade
    • aryano
    • jnolfi
    • joshmk
    • timtifit
    • pdxmjb
    • precisiontongue
    • trevoristall
    • melissawirtz
    • sh4n3droid
    • khaifit
    • elainedev
    • baoifit
    • alla.sheremet
    • hunterifit
    • rshohoney
    • tj-ro
    • jgranny
    • carwbrown
    • rossc-ifit
    • grantb.ifit
    • leggomygrego
    • crsschwalm
    • jackswan
    • mcurcio
    • bleafman
    • scottstav
    • marissac-ifit
    • charlesc-ifit
    • mitchelc
    • jetuni
    • parkerjifit
    • christinav
    • laurels
    • ifit-klims
    • rehan-ifit
    • sgrow-ifit
    • jesshmusic
    • emiifont
    • rashaunw
    • kbgar24-ifit
    • kimberleytippetts
    • den_samiilenko
    • davet2020
    • mahjongg
    • austinwade-ifit
    • mcnewbk
    • ryanb-ifit
    • brandonifit
    • orgri
    • artem_stupachenko
    • angelcontreras
    • designaroni
    • hidekys
    • viktor.brocoders
    • vitalik.ostapenko
    • andrey-bogdan
    • herveweb1
    • kallmon
    • facundo-hm
    • terru
    • sarabadu
    • tolosa
    • sordonez-ns
    • agomezns
    • spatical
    • moisestr
    • irynaalexkomar
    • williampns
    • mm-ifit
    • apukhalsky
    • bradjnewman
    • schepotin
    • stevenschmidt
    • bmalumphy
    • mjnicasource
    • icampsmith
    • michael-nock
    • dc5415
    • vkuznetsov-bro
    • alecmiller
    • mikeb1772
    • ericventor
    • adijensen
    • hurstcr
    • isgabe
    • ramin.rabani
    • alexjvild
    • mhoagland-ifit
    • erice03
    • ariel.aguirre
    • stets10
    • cd1lfit
    • brian.meyer
    • tingey-ifit
    • gavin.lowry
    • niall-mahford
    • shanemoyo
    • jef-hauschild
    • hayesashbyatifit
    • cclayton
    • wisfitdev
    • parkerericson
    • michaelpapesca
    • talleman
    • matsalla
    • fryjus