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

@exocet/pandora-mongodb

v0.0.1-alpha.0

Published

Pandora MongoDB persistence addon

Downloads

2

Readme

Pandora MongoDB

Addon to provide flow and setup functions to MongoDB persistence for Pandora.

npm install --save @exocet/pandora-mongodb

Setup

Available features:

  • Create text indexes
  • Provides AQS query parser
  • Flow steps: insert (index), update, delete, exists and search

To add this addon into your project, put the addon spec into your endpoint YAML:

kind: Pandora/endpoint
metadata:
  name: myEndpoint
spec:
  addons:
    - name: mongodb
      package: "@exocet/pandora-mongodb"
      flow: true
      setup: true
  configuration:
    mongodb: # Any configuration here will be passed to client configuration (1)
      database: myDatabase
      url: mongodb://localhost:27017
      collections:
        - entityName: myNamespace.myEntity # To create index and mapping for an entity, pass the entity name, the settings bellow are the defaults
          textIndex: true
        - collectionName: myCollection
          textIndex: true
  1. Client configuration

After the setup the following property of the context will be available:

  • .application.dbs.mongoClient - The client connected to MongoDB
  • .application.dbs.mongodb - The connected database reference

Hooks

The hooks created by this addon are:

  • mongodbQueryParsers (.service.hooks.useHook('mongodbQueryParsers')) - Synchronous hook that parses the search AQS query into MongoDB aggregation pipeline.
    const [queryParsers] = this.service.hooks.useHook('mongodbQueryParsers');
    const queryParser = queryParsers(entityName);
    const {
    	pipeline, // The aggregation pipeline
    	hasMatch // Boolean to indicate if the pipeline have the match operation
    } = queryParser(
    	aqsQuery,
    	{ // Optional options
    		pipeline: [], // Existent aggregation pipeline
    	}
    );

Flow

The provided flow type and steps are listed bellow:

  • insert - This flow step insert data into MongoDB:
    kind: Pandora/flowStep
    metadata:
      name: entityPersistence
      labels:
        operation: insert
    spec:
      type: mongodb # Flow step type
      options:
        operation: insert # Defines that is an insert operation
        inboundFrom: request.data # The path to the data to be inserted (acquired from execution context)
        idFrom: null # If you want to use a custom ID instead of UUIDv4 you can pass the path from the execution context to get the ID value
        collectionName: null # If you're using custom collection name, pass the name here
        entity: # The entity to define the input parser hook
          namespace: myNamespace
          name: myEntity
  • exists - This flow step check if an entity exists by ID:
    kind: Pandora/flowStep
    metadata:
      name: entityPersistence
      labels:
        operation: exists
    spec:
      type: mongodb
      options:
        operation: exists
        idFrom: request.data.id # The path of the ID
        outboundTo: null # The execution path of the context to put the found ID, is an useful flow step to put before update and delete flows to get the native ID before operating the entity
        collectionName: null
        entity:
          namespace: myNamespace
          name: myEntity
  • update - This flow step updates entities:
    kind: Pandora/flowStep
    metadata:
      name: entityPersistence
      labels:
        operation: update
    spec:
      type: mongodb
      options:
        operation: update
        inboundFrom: request.data
        idFrom: request.data.id # The path of the ID to update entity
        collectionName: null
        entity:
          namespace: myNamespace
          name: myEntity
  • delete - This flow step deletes entities:
    kind: Pandora/flowStep
    metadata:
      name: entityPersistence
      labels:
        operation: delete
    spec:
      type: mongodb
      options:
        operation: delete
        idFrom: request.data.id
        collectionName: null
        entity:
          namespace: myNamespace
          name: myEntity
  • search - This flow step searches for entities using AQS:
    kind: Pandora/flowStep
    metadata:
      name: entityPersistence
      labels:
        operation: search
    spec:
      type: mongodb
      options:
        operation: search
        queryFrom: request.query # The execution context path that have the AQS querystring
        outboundTo: response # The execution context path to put the search result
        pipelineFrom: null # The execution context path that have an existing pipeline instance to append the parsed AQS filters, pass null to indicate the flow step to generate a new instance
        collectionName: null
        entity:
          namespace: myNamespace
          name: myEntity