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

@dadi/api-filestore

v0.11.4

Published

A JSON datastore adapter for DADI API

Downloads

34

Readme

API FileStore Adapter

npm (scoped) Coverage Status Build Status JavaScript Style Guide

Requirements

Install

To use this adapter with your DADI API installation, you'll need to add it to your API's dependencies:

$ npm install @dadi/api-filestore --save

Configure

Configuration Files

Configuration settings are defined in JSON files within a /config directory at the root of your API application. DADI API has provision for multiple configuration files, one for each environment that your API is expected to run under, for example development and production.

A post-install script ran when you installed the package from NPM, creating a development configuration file for you at config/filestore.development.json.

The naming convention for @dadi/api-filestore configuration files follows the format filestore.<environment>.json

For example:

filestore.development.json
filestore.production.json

Application Anatomy

my-api/
  config/            # contains environment-specific configuration properties
    config.development.json
    config.production.json
    filestore.development.json
    filestore.production.json

  main.js            # the entry point of the app
  package.json
  workspace/
    collections/     # collection schema files
    endpoints/       # custom Javascript endpoints

Configuration

The contents of the configuration file should be similar to the following:

{
  "database": {
    "path": "path/to/your/database",
    "autosaveInterval": 10000,
    "serializationMethod": "pretty"
  }
}

Property | Description | Default :--------|:------------|:------- path | The relative or absolute path to where your database files will be stored | none autosaveInterval | The interval, in milliseconds, between database writes to disk | 5000 (5 seconds) serializationMethod | The format of the database file on disk. normal is a condensed version of the JSON, pretty is more readable | normal

Querying Collections

$eq

// explicit
{'Name': { '$eq' : 'Odin' }}

// implicit (assumes equality operator)
{'Name': 'Odin'}

$ne

not equal test

{'legs': { '$ne' : 8 }}

$regex

// pass in raw regex
var results = coll.find({'Name': { '$regex' : /din/ }});

// or pass in string pattern only
results = coll.find({'Name': { '$regex': 'din' }});

// or pass in [pattern, options] string array
results = coll.find({'Name': { '$regex': ['din', 'i'] }});

If using regex operator within a named transform or dynamic view filter, it is best to use the latter two examples since raw regex does not seem to serialize/deserialize well.

$in

var users = db.addCollection("users");
users.insert({ name : 'odin' });
users.insert({ name : 'thor' });
users.insert({ name : 'svafrlami' });

// match users with name in array set ['odin' or 'thor']
{ 'name' : { '$in' : ['odin', 'thor'] } }

$between

// match users with count value between 50 and 75
{ count : { '$between': [50, 75] } }

$contains / $containsAny / $containsNone

var users = db.addCollection("users");
users.insert({ name : 'odin', weapons : ['gungnir', 'draupnir']});
users.insert({ name : 'thor', weapons : ['mjolnir']});
users.insert({ name : 'svafrlami', weapons : ['tyrfing']});
users.insert({ name : 'arngrim', weapons : ['tyrfing']});

// returns 'svafrlami' and 'arngrim' documents
{ 'weapons' : { '$contains' : 'tyrfing' } }

// returns 'svafrlami', 'arngrim', and 'thor' documents
{ 'weapons' : { '$containsAny' : ['tyrfing', 'mjolnir'] } }

// returns 'svafrlami' and 'arngrim'
{ 'weapons' : { '$containsNone' : ['gungnir', 'mjolnir'] } }

Composing Nested Queries

$and

fetch documents matching both sub-expressions

{
  '$and': [{
      'Age' : {
        '$gt': 30
      }
    },{
      'Name' : 'Thor'
    }]
}

$or

fetch documents matching any of the sub-expressions

{
  '$or': [{
      'Age' : {
        '$gte': '40'
      }
    },{
      'Name' : 'Thor'
    }]
}