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

@youmukonpaku/mudb

v1.1.1

Published

To manage your data by a file-based databse!

Downloads

10

Readme

MuDB - A file-based database

一个以基于文件系统和JSON的的轻量级数据库,使用lowdb进行驱动。

使用示例:

  import path from 'path'
  import fs from 'fs'
  import Mudb from '@youmukonpaku/mudb'

  const dbPath = path.join(__dirname, 'db')
  const db = 'testDatabase'
  const col = 'testCollection'

  const Mu = new Mudb(dbPath)

  try {
    Mu.createDatabase(db)
  } catch (e) {
    console.log('Database already exist!')
  }

  Mu.useDatabase(db)

  try {
    Mu.createCollection(col)
  } catch (e) {
    console.log('Collection already exist!')
  }

  Mu.useCollection(col)

  Mu.addDocuments([{
    id: 1,
    name: 'testName',
    time: new Date().getTime()
  }])

  const res = Mu.getDocuments()

  console.log(res)

APIs:

  • 初始化数据库 new Mudb(dbPath: string)

    • 使用当前目录的db文件夹作为数据库存储空间。
    • new Mudb(path.join(__dirname, 'db'))
  • 新建数据库 Mu.createDatabase(dbname: string)

    • 新建testDb数据库。
    • Mu.createDatabase('testDb')
  • 切换数据库 Mu.useDatabase(dbname: string)

    • 将数据库切换为testDb。
    • Mu.useDatabase('testDb')
  • 新建集合 Mu.createCollection(collectionName: string, isAnyCollection?: boolean)

    • 新建testCol集合,第二个参数为集合类型,默认为对象集合。
    • Mu.createCollection('testCol')
  • 切换集合 Mu.useCollection(collectionName: string)

    • 将集合切换为testCol。
    • Mu.useCollection('testCol')
  • 新增记录 Mu.addDocuments(value: object[])

    • 向testCol文档中新增两条记录。
    • Mu.addDocuments([{id: 1, name: 'test'}, {id: 2, name: 'test'}])
  • 获取记录 Mu.getDocuments(filter?: object[])

    • 从testCol中获取记录。
    • const res = Mu.getDocuments()
  • 更新记录 Mu.updateDocuments(filter: object, assign: object)

    • 将testCol中{id: 1}的所有记录name字段更新为newName。
    • Mu.updateDocuments({id: 1}, {name: 'newName'})
  • 删除记录 Mu.removeDocuments(filter: object)

    • 将testCol中{id: 1}的所有记录删除。
    • Mu.removeDocuments({id: 1})