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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fpm-plugin-mongo

v1.2.0

Published

A Plugin Named [fpm-plugin-mongo] For YF-FPM-SERVER~

Downloads

3

Readme

FPM-PLUGIN-MONGODB

用于操作 mongodb 的插件

Install

npm add fpm-plugin-mongo --save

Useage

  • config

    {
      //
      "mongodb": {
        "host": "localhost",
        "port": 27017,
        "poolSize": 5,
        "auth": {
          "user": "admin",
          "password": "admin"
        }
      }
    }
  • api

    • find: find the records
      let data = await fpm.execute('mongo.find', { collection: 'foo', condition: { name: 'bar1' }, limit: 5, sort: 'i-', skip: 5 });
      // data is a array of datas
      /* Find: [ ... ]
      //*/
    • first: get the first record of the matched records
      let { data } = await fpm.execute('mongo.first', { collection: 'foo', condition: { name: 'bar1' }, limit: 5, sort: 'i-', skip: 5 });
      // data is a object or null
      // First: { data: null }
    • create: insert a row
      let data = await fpm.execute('mongo.create', { collection: 'foo', row: { name: 'bar' } });
      // data is a object contains _id
      // Create: { name: 'bar', _id: '5bf2ad16aae34848387dc6c1' }
    • batch: insert rows
      let data = await fpm.execute('mongo.batch', { collection: 'foo', rows: [ { name: 'bar1' }, { name: 'bar12' }, { name: 'bar13' } ] });
      // data is a object contains n, ok
      // Batch: { ok: 1, n: 3 }
    • remove: remove one row
      let data = await fpm.execute('mongo.remove', { collection: 'foo', id: '5bf26e4efdd5f12e08fab6b6' });
      // data is the result, it throws error if not exits
    • save: save one row
      let data = await fpm.execute('mongo.save', { collection: 'foo', id: '5bf26e4efdd5f12e08fab6b6', row: { name: 'modified' } });
      // data is the result, it throws error if not exits
      // { n: 1, nModified: 0, ok: 1 }
    • update: update rows
      let data = await fpm.execute('mongo.update', { collection: 'foo', condition: { name: 'bar' }, row: { name: 'modified' } });
      // data is the result
      // Update: { n: 11, nModified: 1, ok: 1 }
    • clean: clean the records
      let data = await fpm.execute('mongo.clean', { collection: 'foo', condition: { name: 'bar1' } });
      // data is a array of datas
      // Clean: { n: 1, ok: 1 }
    • count: count the records
      let data = await fpm.execute('mongo.count', { collection: 'foo', condition: { name: 'bar1' }});
      // data is a array of datas
      // Count: { count: 40 }
    • find: findAndCount the records
      let data = await fpm.execute('mongo.findAndCount', { collection: 'foo', condition: { name: 'bar1' }, limit: 5, sort: 'i-', skip: 5 });
      // data is a array of datas
      /* FindAndCount: { count: 40,
          rows: [ ... ]
        }
        //*/

Mongodb Manual

Backup the db

# run docker exec

docker exec -it mongo_server /bin/bash

# mongodump -h 127.0.0.1 --port 27017 -u [user] -p [pass] -d [dbname] -o /backup/dump --authenticationDatabase admin
# tar -zcvf testDB.tar.gz /backup/dump/testDB
# remove the dir
mongodump -u admin -p admin --authenticationDatabase admin -o /backup/dump  \
&& tar -C /backup/dump -zcvf /backup/all.tar.gz . \
&& rm -rf /backup/dump/*

Store the db

注:

1、mongorestore恢复数据默认是追加,如打算先删除后导入,可以加上--drop参数,不过添加--drop参数后,会将数据库数据清空后再导入,如果数据库备份后又新加入了数据,也会将新加的数据删除,它不像mysql有一个存在的判断。

# run docker exec

docker exec -it mongo_server /bin/bash

# unzip && restore all dbs
tar -C /backup/store -zxvf /backup/all.tar.gz \
&& mongorestore -u admin -p admin --authenticationDatabase admin --drop /backup/store/  \
&& rm -rf /backup/store/*