Socket
Book a DemoInstallSign in
Socket

build-db-index

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-db-index

build db index by config

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

what to handle

build mongodb indexes by config file

how to use

npm install build-db-index

async function build() {
    await setIndex({uri:"mongodb://127.0.0.1:27017",db:"test"},
    {
        offer:[
            {key:{offer_id:1,time:1}},
            {key:{ttl:1},options:{expireAfterSeconds:2600}}
        ],
        user:[{key:{userid:1},options:{unique:true}}]
    })
}

build().catch(console.error);

excuted build(),the db 'test' will build the indexes of collection offer and user,

and drop all indexes( of all collections defined in config) that not defined in config.

If index exists(key and options are both same ),it will not take time to rebuild it.

Keywords

db

FAQs

Package last updated on 04 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts