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

@journaly/j-db-client

v13.23.0

Published

Journaly's internal database client.

Downloads

24

Readme

J-DB-Client

An internal database client that can be imported into any of the other Journaly services in order to perform database operations. It is published on NPM by the Journaly NPM organization and thus any changes need to be versioned and published (see steps below – access to the Journaly NPM account is required).

  • This package is built with Prisma, which generates type-safe database queries are mutations based on our data model (or schema) which lives in prisma/schema.prisma.
  • When this package is installed within one of our services, a PrismaClient that contains all of these database operations is generated and can then be imported and used as needed.

Updating the datamodel

If you need to update the data model, you'll need to follow these steps:

  1. Make your change in prisma/schema.prisma.
  2. Run npm run migrate:create and choose a descriptive name, such as add-pending-notification-table - this will generate a new directory within ./prisma/migrations that contains the files for your migration.
  3. Run npm run migrate:apply to apply this migration to your local database instance.

Migrations

Database migrations are how changes to the data model(schema.prisma) get applied to a database. Changes that you make to the data model in your local environment also need to be applied to databases in other environments, e.g. production, and migrations are how that change is reproduced elsewhere. If you edit the data model, you'll want to run the following commands:

1. From the packages/j-db-client directory:

$ npm run migrate:create
$ npm run migrate:apply
  • The first command creates a migration, resulting in a new file in the j-db-client/prisma/migrations directory.
  • The second applies that migration to the local database. This helps you to do an initial test on if there are any issues with the migration.

2. Publish new j-db-client version

In order to use fields from this migration in the web app/package, you need to publish a new version of j-db-client to the NPM registry so that it can be installed in our application's other packages (currently web and j-mail).

Steps:

  1. Bump the version of this package in package.json. Please follow semver and feel free to ask us if you have any doubts.
  2. Run npm run build.
  3. Run npm publish to publish this new version to the NPM registry.

3. From the packages/web directory:

$ npm i @journaly/j-db-client
  • This installs that latest version to your local web package and a post-install hook is run that regenerates your PrismaClient. If you have any problems with this, you can manually regenerate the PrismaClient by running npm run prisma:generate.
  • You'll want to commit any new migration artifacts that you create.

NOTE: Previous migrations should never be edited.