Socket
Book a DemoInstallSign in
Socket

@pubsweet/db-manager

Package Overview
Dependencies
Maintainers
5
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pubsweet/db-manager

Provides database management utilities to Pubsweet apps.

3.1.26
latest
npmnpm
Version published
Weekly downloads
175
-22.57%
Maintainers
5
Weekly downloads
 
Created
Source

Provides database management utilities to Pubsweet apps.

Usage

This package exports the following functions:

  • setupDb
  • addUser
  • dbExists
  • migrate

setupDb

This function

  • creates the database
  • adds an admin user
  • generates a secret in config/local-<NODE_ENV>.json under pubsweet-server.secret.

It can be called without arguments, in which case it will take its configuration from the following config keys:

{
  'pubsweet-server': {
    db: {
      //  takes the same configuration options as https://node-postgres.com/features/connecting#programmatic
    }
  },
  dbManager: {
    username: 'xxxxxx',
    password: 'pppppp',
    email: 'email@example.com',
    clobber: false // overwrite existing db (optional)
  }
}

Alternatively it can be passed the dbManager object as an argument, which will override the values on config.

The name of the database will be the full dbPath.

addUser

This function adds a user to an already existing database. It requires a user object as argument:

addUser({
  username: 'xxxxxx',
  password: 'pppppp',
  email: 'email@example.com',
  admin: true, // (optional)
})

dbExists

This function checks if any database exists at the configured path. Returns true or false

migrate

This function performs pending migrations.

Keywords

pubsweet

FAQs

Package last updated on 08 Jun 2021

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.