Registry / database / congress-mongodb

congress-mongodb

JSON →
library1.2.0jsnpmunverified

CLI and library for downloading United States Congress data (sitemaps, JSON) and importing it into MongoDB via Mongoose schemas. Version 1.2.0, last updated in 2018. Requires external CLI tools (congress, congress-legislators) and MongoDB 3.2+. Provides predefined models (Member, etc.) and a convenience connect() function. No active updates; dependencies are outdated.

npm install congress-mongodb
INSTALL
IMPORT
SIG · CONGRESS-MONGODB
C
congress-mongodb
databasejavascriptv1.2.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.

default export
import congress from 'congress-mongodb'
const congress = require('congress-mongodb'); // CJS may work but ES import is recommended
The default export is an object with connect and models functions.
connect
import congress from 'congress-mongodb'; congress.connect(mongoose, uri)
const { connect } = require('congress-mongodb'); // works but ES import is preferred
connect() returns a promise with db object containing models.
models
import congress from 'congress-mongodb'; congress.models(mongoose)
models() returns an object of Mongoose models for use with existing connection.

Connects to MongoDB, fetches current members of Congress, and prints them.

import congress from 'congress-mongodb'; import mongoose from 'mongoose'; const uri = process.env.MONGODB_URI ?? 'mongodb://localhost:27017/congress'; congress.connect(mongoose, uri) .then(db => { db.Member.find({ current: true }) .then(members => { console.log(members.join('\n')); }); }) .catch(err => console.error(err));
Debug
Known issues
gotchaThe CLI commands 'congress fetch' and 'congress sync' clash with the external 'congress' npm package. Use full path './node_modules/.bin/congress' to avoid conflicts.
fix
Run './node_modules/.bin/congress fetch' or install globally with a different name.
affects: >=1.0.0
deprecatedThe peer dependency mongoose@^4.0.0 is outdated. Mongoose 5+ uses different connection logic and may break connect().
fix
Pin mongoose to 4.x or update the package to support newer versions.
affects: >=1.0.0
breakingThe package uses an external 'congress' CLI that may no longer work with current data sources. The United States Congress API may have changed.
fix
Check the upstream 'congress' package for updates; this package may not work as expected.
affects: >=1.0.0
gotchaThe connect() function requires both mongoose and a URI; omitting the URI will throw an error. The environment variable MONGODB_URI is not used automatically.
fix
Always pass a URI string or ensure MONGODB_URI is set and passed explicitly.
affects: >=1.0.0
gotchaThe package does not export individual models; use congress.connect() or congress.models() to obtain them. Direct imports like 'congress-mongodb/models/Member' will fail.
fix
Use the default import and call models() or connect().
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'mongoose'
Mongoose is not installed or is not in node_modules.
fix
Install mongoose: npm install mongoose@^4.0.0
TypeError: congress.connect is not a function
Incorrect import: using a named import like { connect } instead of default import.
fix
Use: import congress from 'congress-mongodb'
Error: connect() requires mongoose and a URI
Missing or undefined arguments to connect().
fix
Call congress.connect(mongoose, uri) with both arguments.
Error: listen EADDRINUSE :::27017
MongoDB is already running on default port.
fix
Use a different port or stop existing MongoDB instance.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
mongooserequiredpeer dependency for integration; provides MongoDB ODM schemas
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
congress-mongodb — npm install congress-mongodb · libregistry