1.1.1 • Published 5 years ago

@ibberson92/mongodb-connector v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

mongodb-connector

Under development. Some unit tests left to write and additional methods.

This module does not introduce application-level caching. It leverages DataLoader's memoization cache to reduce MongoDB loads only. Please fork this project if you wish to integrate such functionality or open an "enhancement" issue for me to review.

Connector Export

MethodDescriptionParametersResponse
connectEstablishes database connectionURI (string), database name (string), MongoClient options(object)object
disconnectTerminates active database connectionn/aundefined
getCollectionCreates a collection or loads an existing oneCollection name (string), options objectobject

Loader Export

As you'll see, this export wraps only the most popular collection methods. There will be instances where you must call the collection directly (i.e. to count or watch), at which point I recommend storing the collection reference externally after instantiating the Connector class.

I suspect that I will introduce new methods over time. If there's one you'd like to see, please message me and I'll implement.

MethodDescriptionParametersResponseCached/Batched
batchByIdBatch find requestsObjectId(array)arrayyes
findLookup paginated resultsQuery options(object)arrayno
findOneFind single document by queryQuery options(object)objectno
findOneFind single document by IDObjectId(string)objectno
createOneInsert new documentPayload(object)objectno
updateByIdUpdate an existing documentObjectId(string), payload with operators(object)objectyes
deleteByIdRemove an existing document or mark it invisible with custom propertyObjectId(string),property name(string)booleanyes