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

import-nodeserver-database

v1.0.0

Published

Imports a subset of the nodeserver database base on the specified criteria

Downloads

6

Readme

Iamat-Db-Subset

Nodejs script for the import of a subset of another Iamat database.

Requirements

This script is designed to work with the same requirements of the nodeserver implementation.

Beside the script must have access to a local mongodump and mongorestore executable files. Those files may ship altoether with the scripts depending on the platform.

How it works:

Importing an atcode

node importDbSubset.js --atcodes someatcode --filter someconfigfile.json

Importing several atcodes

node importDbSubset.js --atcodes someatcode,test,yog18 --filter someconfigfile.json

Use Cases:

To add an atcode to an existing database use somthing like

node importDbSubset.js --atcodes someNEWatcode --filter someconfigfile.json --clean

In this case the clean parameter is necesary to allow to dump the collections. It cannot override the files already in the filesystem.

Other option would be to use another dump directory.

To replace the existing database with some other atcode use somthing like

node importDbSubset.js --atcodes someNEWatcode --filter someconfigfile.json --clean --drop

To restore the database to the last import state use something like

node importDbSubset.js

Configuration

There is a base configuration in the baseConfig.json file with some posible configurations for the script.

  • "host": Host for the origin mongo database
  • "lhost": Host for the destination mongo database
  • "port": port for the origin mongo database
  • "lport": port fot the destination mongo database
  • "user": user for the origin mongo database
  • "luser": user for the destination mongo database
  • "password": password for the origin mongo database
  • "lpassword": password for the the destination mongo database
  • "db": database for the origin
  • "ldb": database for the destination
  • "maxDays": Default days to count back for filter the records of very populated collections. It is used to calculate the minDate for the records in the collection. For example: if its set to 30, the collections that are marked to be filtered by date will import the records created(not updated) in the last 30 days.
  • "atcodes": ARRAY =>the atcodes to checkout.
  • "dumpDir": the directory where the dump will be stored.
  • "collectionFilter": The collections to import.
  • "collectionWithDateFilter": collections with filter by id creation date. see maxDays.
  • "collections": Object of filters by collection to be applied while dumping.

See the file baseConfig.json for examples and default values.

Override of values in the command line

Those configurations may be overrided in the command line by args parameters.

Beside there are two possible args that can be specified to provide more control.

  • atcodes: separated by commas: ex: test,yog18,mitelefe, Will override the atcodes configured in the config files.
  • clean: Will erase the temp folder with the dumps and import everything again.
  • dumpOnly: Will only dump the collections into the dump folder.
  • drop: Will only drop the collections that are going to be restored again. ex.
node importDbSubset.js --host localhost --port 27010 -u user -p password --filter myconf.json --atcodes superatcode,test,yog18 --clean --drop