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

treestorage

v1.0.4

Published

A fully open source database building tool for node.js

Downloads

3

Readme

npm treestorage 1.0.2 🌳

A fully open source database building tool for node.js

install :

npm i treestorage

example 1 - branch with leaf 🌿

let treeStorage = require("treestorage")

let database = treeStorage(__dirname+"/database")

database.users = {
  name:{type:String,require:true,maxSize:30},
  surname:{type:String,require:true,maxSize:30},
  email:{unique:true,type:String,require:true,maxSize:100,lowerCase:true,match:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,solid:true},
  password:{type:String,require:true,maxSize:35,minSize:8,private:true},
}

let __db = database();

__db.create({
  name:"Damian",
  surname:"Mostert",
  email:"[email protected]",
  password:"password1"
},result=>{
  console.log(result)
})

console.log(__db.search({name:"d"}))
output
let treeStorage = require("treestorage")

let database = treeStorage(__dirname+"/database")

database.users = {
  name:{type:String,require:true,maxSize:30},
  surname:{type:String,require:true,maxSize:30},
  email:{unique:true,type:String,require:true,maxSize:100,lowerCase:true,match:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,solid:true},
  password:{type:String,require:true,maxSize:35,minSize:8,private:true},
}

let __db = database();

__db.create({
  name:"Damian",
  surname:"Mostert",
  email:"[email protected]",
  password:"password1"
},result=>{
  console.log(result)
})

console.log(__db.search({name:"d"}))

example 2 - leaf 🍃

let treeStorage = require("treestorage")

let users = treeStorage.leaf(__dirname+"/users",{
  name:{type:String,require:true,maxSize:30},
  surname:{type:String,require:true,maxSize:30},
  email:{unique:true,type:String,require:true,maxSize:100,lowerCase:true,match:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,solid:true},
  password:{type:String,require:true,maxSize:35,minSize:8,private:true},
})

users.create({
  name:"Damian",
  surname:"Mostert",
  email:"[email protected]",
  password:"password1"
},result=>{
  console.log(result)
})

users.searchOne({name:"d"},user=>{
  if(user){
    console.log(user.change({name:"Bob",surname:"Lukas"}))
  }
})

console.log(users.getAll())

console.log(users.deleteAll())
output
{ errors: [], success: 'item made' }
{ errors: [], success: 'item updated' }
[
  {
    name: 'Bob',
    surname: 'Lukas',
    email: '[email protected]',
    password: 'password1',
    __v: 1,
    __id: '4GW5VxQSIDeRlykS39S9eyEd90dIsnNDeK11OaR0eGqSnXyQ1rZdkMVoOW4o68meG8QBFnvuOzU',
    __dir: '/home/damian/Desktop/d/users/4GW5VxQSIDeRlykS39S9eyEd90dIsnNDeK11OaR0eGqSnXyQ1rZdkMVoOW4o68meG8QBFnvuOzU',
    delete: [Function],
    update: [Function],
    change: [Function]
  }
]
[ { success: 'item removed' } ]

example 3 - branch 🌿

let treeStorage = require("treestorage")

let userTemplate = {
  name:{type:String,require:true,maxSize:30},
  surname:{type:String,require:true,maxSize:30},
  email:{unique:true,type:String,require:true,maxSize:100,lowerCase:true,match:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,solid:true},
  password:{type:String,require:true,maxSize:35,minSize:8,private:true},
}

let users = treeStorage.leaf(__dirname+"/users",userTemplate)

let database2 = treeStorage(__dirname+"/database")

database2.users = userTemplate

let __db = database2();

let fullDB = treeStorage.branch({
  backup:__db,
  main:users
})

fullDB.create({
  name:"Damian",
  surname:"Mostert",
  email:"[email protected]",
  password:"password1"
},result=>{
  console.log(result)
})

console.log(fullDB.getAll())

console.log(fullDB.deleteAll())
output
{
  backup: { users: { errors: [], success: 'item made' } },
  main: { errors: [], success: 'item made' }
}
{
  backup: { users: [ [Object] ] },
  main: [
    {
      name: 'Damian',
      surname: 'Mostert',
      email: '[email protected]',
      password: 'password1',
      __v: 0,
      __id: 'iP173bwqih5tjPz4o4xKCouL8yB2uMhnIdQOpFp1GDtq1DfoVrr2xiecA4zQ7Rb7bCVQKVltPcy',
      __dir: '/home/damian/Desktop/d/users/iP173bwqih5tjPz4o4xKCouL8yB2uMhnIdQOpFp1GDtq1DfoVrr2xiecA4zQ7Rb7bCVQKVltPcy',
      delete: [Function],
      update: [Function],
      change: [Function]
    }
  ]
}
{
  backup: { users: [ [Object] ] },
  main: [ { success: 'item removed' } ]
}

leaf template options

| option name | explenation | santax usage | | ------------- |:-------------:|:-------------:| | unique | makes shure there wont be a duplicate inside leaf object |{type:Array,}| | private | will disable all finding and searching by this object |{private:true,}| | type | wont create item if it is the incorect type | {type:Object,} {type:String,} {type:Array,} {type:Number,} | | match | same as using String.match(/a-x/) match is good to check emails and passwords | {match:/a-z/,} | | require | won't create item without this data | {require:true,} | | size | wont create item if String.length or Number not == to size | {size:5,} | | minSize | wont create item if String.length or Number not >= to size | {minSize:2,} | | maxSize | wont create item if String.length or Number not <= to size | {maxSize:10,} | | lowerCase | will automaticly save as lowerCase if String | {lowerCase:true,} | | upperCase | will automaticly save as upperCase if String | {upperCase:true,} | | solid | if a storage item on leaf set to solid, it canot be changed | {solid:true,} |

leaf and branch tool list

| tool name | explenation | santax | santax with callback example | | ------------- |:-------------:|:-------------:|:-------------:| |getAll| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |create| used make a item in a leaf or items in branch object | All=object.getAll()|object.getAll(All=>{})| |find| used to find multiple objects with exact match to filter| results=object.find({/*filter_data*/})|object.find({/*filter_data*/,results=>{})| |findOne| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |findById| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |search| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |searchOne| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |searchOneUpdate| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |searchById| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |update| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |updateMult| used to update multipe items in leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |updateById| used to update items in a leaf object by there .__id value| All=object.getAll()|object.getAll(All=>{})| |updateAll| used to update all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |delete| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |searchOneDelete| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |searchDelete| used to get all items in a leaf or branch object | All=object.getAll()|object.getAll(All=>{})| |deleteById| used to delete a object by its .__id value | result=object.getAll()|object.getAll(All=>{})| |deleteMult| used to delete multiple items in database with find results | results=object.deleteMult({/*find_filter*/})|object.deleteMult({/*find_filter*/},results=>{ })| |deleteAll| deletes all in leaf or branch | result=object.deleteAll()|object.deleteAll(result=>{})|

treeStorage database object structure example

branch {
  path: { users: '/home/damian/Desktop/d/database/users' },
  rules: {
    users: {
      name: [Object],
      surname: [Object],
      email: [Object],
      password: [Object]
    }
  },
  getAll: [Function: getAll],
  create: [Function: create],
  find: [Function: find],
  findOne: [Function: findOne],
  findById: [Function: findById],
  search: [Function: search],
  searchOne: [Function: searchOne],
  searchUpdate: [Function: searchUpdate],
  searchOneUpdate: [Function: searchOneUpdate],
  searchById: [Function: searchById],
  update: [Function: update],
  updateMult: [Function: updateMult],
  updateById: [Function: updateById],
  updateAll: [Function: updateAll],
  delete: [Function: deleteOne],
  deleteById: [Function: deleteById],
  searchOneDelete: [Function: searchOneDelete],
  searchDelete: [Function: searchDelete],
  deleteMult: [Function: deleteMult],
  deleteAll: [Function: deleteAll],
  users: leaf {
    path: '/home/damian/Desktop/d/database/users',
    rules: {
      name: [Object],
      surname: [Object],
      email: [Object],
      password: [Object]
    },
    getAll: [Function: getAll],
    create: [Function: create],
    find: [Function: find],
    findOne: [Function: findOne],
    findById: [Function: findById],
    search: [Function: search],
    searchOne: [Function: searchOne],
    searchOneUpdate: [Function: searchOneUpdate],
    searchUpdate: [Function: searchUpdate],
    searchById: [Function: searchById],
    update: [Function: update],
    updateMult: [Function: updateMult],
    updateById: [Function: updateById],
    updateAll: [Function: updateAll],
    delete: [Function: deleteOne],
    searchOneDelete: [Function: searchOneDelete],
    searchDelete: [Function: searchDelete],
    deleteById: [Function: deleteById],
    deleteMult: [Function: deleteMult],
    deleteAll: [Function: deleteAll]
  }
}

| Auther | Damian Mostert | | ------------- |:-------------:| | Email | [email protected] | | Time it took to build this project till this point | 24h00 (one day) |