Registry / database / eosio-mongodb-queries

eosio-mongodb-queries

JSON →
library0.9.0jsnpmunverified

A library for building complex MongoDB queries for the EOSIO blockchain. Version 0.9.0 provides helper functions to query account info, actions, blocks, and more from an EOSIO node's MongoDB database. It wraps the MongoDB aggregation pipeline with pre-built stages for common EOSIO data patterns. Compared to raw MongoDB queries, it abstracts the schema details and provides typed query helpers. The library ships TypeScript definitions. It is stable but rarely updated; the last release was several years ago. It targets Node.js and browser environments.

npm install eosio-mongodb-queries
INSTALL
IMPORT
SIG · EOSIO-MONGODB-QUER
E
eosio-mongodb-queries
databasejavascriptv0.9.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.

getAccount
import { getAccount } from 'eosio-mongodb-queries'
const getAccount = require('eosio-mongodb-queries').getAccount
Library supports both ESM and CJS; named export.
Internal module or default import
import * as queries from 'eosio-mongodb-queries'
import queries from 'eosio-mongodb-queries'
No default export; must use named or namespace import.
getActions
import { getActions } from 'eosio-mongodb-queries'
Similar to getAccount, this is a named export.

Demonstrates connecting to a local MongoDB and fetching account data using the getAccount helper.

import { MongoClient } from 'mongodb'; import { getAccount } from 'eosio-mongodb-queries'; (async () => { const client = await MongoClient.connect('mongodb://localhost:27017', { useNewUrlParser: true }); const options = { gte_block_num: 0, lte_block_num: Infinity }; const result = await getAccount(client, 'eosnationftw', options); console.log(result); })();
Debug
Known issues
gotchaMongoDB must have the EOSIO mongo_db_plugin enabled and the blockchain replayed for actions to be decoded.
fix
Enable plugin in nodeos config and replay with --replay-blockchain --hard-replay-blockchain --mongodb-wipe.
affects: >=0.0.0
gotchaThe library assumes a specific MongoDB schema that may change between EOSIO versions.
fix
Ensure your EOSIO node version matches the schema expected by the library version.
affects: >=0.0.0
deprecatedThe MongoDB driver option useNewUrlParser is no longer needed in recent mongodb driver versions.
fix
Remove { useNewUrlParser: true } from MongoClient.connect for mongodb driver v4+.
affects: >=4.0.0
Errors
Common errors & fixes
MongoError: Authentication failed
MongoDB connection URI credentials are missing or incorrect.
fix
Provide a valid mongodb-uri in nodeos config, e.g., mongodb://user:pass@localhost:27017/EOS
TypeError: client.db is not a function
Passed a MongoClient that is not yet connected, or the library expects a different client object.
fix
Ensure you await MongoClient.connect and pass the returned connected client.
Upgrade
Version history
0.9.0latest on npm
Audit
Dependencies
mongodbrequiredPeer dependency required for MongoDB client connection
Agent activity
8 hits · last 30 days
node
6
Resources
eosio-mongodb-queries — npm install eosio-mongodb-queries · libregistry