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

lowkie

v1.4.0

Published

My Custom lowkie / Express Applcation

Downloads

66

Readme

Lowkie

Build Status NPM version Coverage Status Join the chat at https://gitter.im/typesettin/lowkie

Description

Lowkie is a lokijs object modeling tool designed to work in an asynchronous environment.

Installation

$ npm i lowkie

Full Documentation

Usage (basic)

//lowkie singleton
const lowkie = require('lowkie');

//connect to lowkie (includes loki connection configuration), options can include other loki adapters besides structured file adapters
lowkie.connect(path.join(__dirname, './sampledb.json'),options)
  .then((db) => { 
    console.log('connected db');
  })
  .catch(e => {
    console.log('connection error', e);
  });

//listen for connection errors
lowkie.connection.on('connectionError', (e)=>{
  console.log('error connecting to the db',e);
});

//listen for connecting status, dbname is the path to the db json file
lowkie.connection.on('connecting', (dbname, options)=>{
  console.log('now trying to connect to db');
});

//once connected, create models, query the db, etc
lowkie.connection.once('connected', (db, options)=>{
  console.log('now connected to db');
  //create a new schema
  const UserSchema = lowkie.Schema({
    email:String,
    username:String,
    age:Number,
  });
  //register db models, each model is a proxied loki collection with additional helpers
  const User = lowkie.model('User',UserSchema);

  //write data to db
  User.insert({
    email:'[email protected]',
    username:'testuser',
    age:30,
    invalidProp:'whatever', //removes invalid schema props on creates
  })
    .then(newuser => {
      //created db
      /*
      {
        "_id":"fbd8080a9272ecaa15d1bb6d0f4b3314",
        "email":"[email protected]",
        "username":"testuser",
        "age":30,
        "meta":{
          "revision":0,
          "created":1490576236063,
          "version":0
        },
        "$loki":201
      }
      */
      console.log({ newuser });
    })
    .catch(e => { 
      console.log(e);
    });
  
  //insert multiple documents
  User.insert([
    {
      email:'[email protected]',
      username:'jsmith',
      age:37,
    },
    {
      email:'[email protected]',
      username:'jdoe',
      age:45,
    },
    {
      email:'[email protected]',
      username:'clane',
      age:17,
    },
  ])
    .then((newusers)=>{
      console.log(newusers);
    })
    .catch(e =>{
      console.log(e);
    })
  
  //query loki for data
  let userQueryResults = User.find({ id: { '$gte': 1 } });
  console.log({userQueryResults}) //result of user query
});

Development

Make sure you have grunt installed

$ npm i -g grunt-cli jsdoc-to-markdown

For generating documentation

$ grunt doc
$ jsdoc2md lib/**/*.js index.js > doc/api.md

Notes

Testing

$ npm i
$ grunt test

Contributing

fork and create a pull request!

Loki Party

License

MIT