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 🙏

© 2026 – Pkg Stats / Ryan Hefner

graphml-views-mongodb

v1.2.1

Published

Generate collections from a MongoDB datasource by given graphml files

Downloads

38

Readme

Graphml-views-mongodb

NPM version Build status Dependency Status Downloads

A library that enable views for MongoDB based on GraphML, which generates collections from MongoDB datasources by given graphml files.

Installation

$ npm install graphml-views-mongodb --save

Why create this?

The original MongoDB doesn't support view like CouchDB and other SQL-Like database. And it supports the following ways to make relations between multiple collections:

  • embed documents
  • DBRef type to reference to other database

weakness of the above ways to relate collections

The embed documents even though has a avilability for retrieving data, but lack of consistency on writing data on the embeded documents.

The DBRef is not recommended way to take the role of expressing relations, we should use it to reference a value to another database that maybe in other system.

about loopback.io

The next context is about Loopback, the framework to replace the role of Parse and LeanCloud, the framework abstracts most popluar databases into the same one schema, and it support rich relations as below:

  • one-to-one
  • one-to-many

That's good, but not enough, because Loopback's scoping/joining syntax is such complicated so that the request URLs would become too long and unreadability. So sometimes, the truth is that we want a collection is for a view, and we just query it directly from the collection without scoping and joining. At the same time, for write operations, we hope that model-based would be used and it will updates data to the view collections.

why GraphML?

In starting this project, we tried JSON, YAML and TOML to express what fields would be in our view collection, but they are almost out after having a try on GraphQL, and then we found GraphQL is the QL for querying, so we, the WeFlex team decoded to rewrite a new marked language based on basic of GraphQL, that's the GraphML.

To express a view, you just need the following:

User {
  username,
  nickname,
  sex,
  country,
  orgs {
    name
  },
  followings {
    username,
    avatarUrl
  },
  followers {
    username,
    avatarUrl
  }
}

Then you will get document:

{
  "_id": "id",
  "username": "yorkie",
  "nickname": "yorkie",
  "sex": "female",
  "country": "internet",
  "orgs": [
    {
      "_id": "weflex_id",
      "name": "weflex"
    }
  ],
  "followings": [
    {
      "_id": "following_id",
      "name": "substack",
      "avatarUrl": "image url"
    }
  ],
  "followers": [
    {
      "_id": "follower_id",
      "name": "scott",
      "avatarUrl": "image url"
    }
  ]
}

How it works

The Graphml-views-mongodb does parse a GraphML file and get fields collection that you want to include from the source collections, and read the relations from pre-defined Loopback models, and generate the complete documents.

API

  • parseGraphs(models, dataSources)
    • models {Array} the object returned from loopback
    • dataSources {Object} the object to take dataSources
      • rest {MongoDB} the resouce database instance
      • view {MongoDB} the view database instance
    • dir the dirname path

License

MIT @ WeFlex, Inc.