npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ranvier-mongodb-datasource

v1.0.0

Published

A set of MongoDb datasources for Ranvier MUD

Downloads

3

Readme

Description

A set of MongoDb datasources for Ranvier MUD that uses The official MongoDB Driver for Node.js.

Prerequisites

  1. You must have a MongoDb database setup and ready to accept connections.

    1. Free Cloud Hosting with MongoDb Atlas
    2. Locally Hosted Installation Guide
  2. You must have a Ranvier Mud project created that you intend to add the datasources to.

    1. Get Started

DataSources

  • MongoDbArrayDatasource: For use with all entities expected to return an array from fetchAll() like: rooms, items, npcs, and quests.
  • MongoDbObjectDatasource: For use with all entities expected to return an object (dictionary) from fetchAll() like: accounts, players, help, and areas.

Registration in ranvier.json

Each datasource requires a config containing the database connection information inside the dataSources section of ranvier.json. And each entitySource requires a config containing the collection name to be used.

Note: You should never store your database connection in the ranvier.json file, see the Ranvier Docs for instructions on how to use a .env file and ranvier.conf.js to secure sensitive data.

Note: The collection name does not support any token insertion, collection names like [AREA]-rooms will not be changed. The datasources already handle bundle and area filtering, so all entities of the same type can be stored in the same collection. See the Developer's Note below.

Example:
{
  "dataSources": {
    "MongoDbArray": {
      require: "ranvier-mongodb-datasource.MongoDbArrayDatasource",
      config: {
        host: '<domain:port>',
        user: '<username>',
        pass: '<password>',
        name: '<database-name>',
      },
    },
    "MongoDbObject": {
      require: "ranvier-mongodb-datasource.MongoDbArrayDatasource",
      config: {
        host: '<domain:port>',
        user: '<username>',
        pass: '<password>',
        name: '<database-name>',
      },
    }
  },
  "entitySources": {
    "areas": {
      "source": "MongoDbObject",
      "config": {
        "collection": "areas"
      }
    },
    "rooms": {
      "source": "MongoDbArray",
      "config": {
        "collection": "rooms"
      }
    },
  }
}

Developer's Note about MongoDb's _id Field

MongoDb requires that all documents have a primary key field named _id. The datasource will populate this field with the entity id (converted to uppercase if string), area name, and bundle name provided by the Ranvier engine.

Example:
{
  bundle: "bundle-example-areas",
  area: "limbo",
  id: "WHITE",
}

For entities which would not be part of an area (help), or which would not be part of a bundle (players, accounts), those fields will be omitted from the _id object. The datasources are aware of this schema, and will apply the appropriate bundle and area filters when querying for entities.