Registry / database / keyvalify

keyvalify

JSON →
library0.1.0jsnpmunverified

A lightweight key-value store built on top of MongoDB, providing a simple get/set/getMany API with optional custom serialization. Version 0.1.0 is in early development with no stable release cadence. Differentiates from other KV stores by leveraging MongoDB's flexibility and your own database connection, with TypeScript generics for type safety. Currently supports only asynchronous operations and a single collection per instance.

npm install keyvalify
INSTALL
IMPORT
SIG · KEYVALIFY
K
keyvalify
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

keyvalify
import { keyvalify } from 'keyvalify'
const keyvalify = require('keyvalify')
The library is ESM-only, so require() will fail with Module not found error.
KeyvalifyOptions
import type { KeyvalifyOptions } from 'keyvalify'
import { KeyvalifyOptions } from 'keyvalify'
KeyvalifyOptions is a type and should be imported using type-only import to avoid runtime overhead.
keyvalify (default)
import { keyvalify } from 'keyvalify'
import keyvalify from 'keyvalify'
There is no default export; only named export exists.

Initializes a key-value store with MongoDB, sets a document, retrieves it, and fetches multiple keys.

import { keyvalify } from 'keyvalify' import { MongoClient } from 'mongodb' const mongoClient = new MongoClient(process.env.MONGO_URI ?? 'mongodb://localhost:27017') await mongoClient.connect() const db = mongoClient.db('test') const kv = keyvalify<{ name: string; age: number }>({ db, collectionName: 'users', }) // Set a value await kv.set('user:1', { name: 'Alice', age: 30 }) // Get a value const user = await kv.get('user:1') console.log(user) // { name: 'Alice', age: 30 } // Get multiple values const users = await kv.getMany(['user:1', 'user:2']) console.log(users) // array of values or null for missing keys await mongoClient.close()
Debug
Known issues
breakingkeyvalify requires MongoDB driver v5 or higher. Using older versions will cause runtime errors.
fix
Update mongodb dependency to ^5.0.0 or later.
affects: >=0.0.0
gotchaThe database connection must be established before calling keyvalify; otherwise, operations will fail with a connection error.
fix
Ensure await mongoClient.connect() is called before initializing kv.
affects: >=0.0.0
deprecatedThe 'options' parameter for keyvalify is currently required; leaving it empty will throw a TypeError.
fix
Always provide an options object with at least { db, collectionName }.
affects: 0.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'collection')
keyvalify was called without the db property in options.
fix
Pass a valid MongoDB Db object: keyvalify({ db: yourDb, collectionName: '...' })
MongoParseError: option useNewUrlParser is not supported
Using an older MongoDB connection string with deprecated options.
fix
Remove useNewUrlParser and useUnifiedTopology from MongoClient options.
TypeError: keyvalify is not a function
Importing as default export instead of named export.
fix
Change to: import { keyvalify } from 'keyvalify'
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
mongodbrequiredRequired to connect to MongoDB and perform operations
Agent activity
5 hits · last 30 days
node
4
Resources
keyvalify — npm install keyvalify · libregistry