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

@heduapp/book-objects-db

v0.33.5

Published

## Usage ### Install - Configure [SSH Config](http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/) to access GitHub. - Pick your version, from [releases](https://github.com/HeduApp/book-objects/releases). ``` npm install git+ssh://

Downloads

34

Readme

Book Objects Database

Usage

Install

npm install git+ssh://ssh-config-name:HeduApp/book-objects-db.git#v0.1.0

DB Codec prerequisites

npm install objection knex mysql
import { DBCodec } from '@heduapp/book-objects-db';
const dbCodec = new DBCodec({
    client: 'mysql',
    connection: {
        host: '127.0.0.1',
        user: 'bo',
        password: 'bo',
        database: 'bo-dev',
    },
    seeds: {
        directory: './seeds/production',
    }
});

Decode business object from DB

import * as BO from '@heduapp/book-objects/business-object'
import { DBCodec } form '@heduapp/book-objects-db'
const dbCodec = new DBCodec();
const book = (await dbCodec.decode(bookUUID)) as BO.Book;

Encode business object into DB

import { DBCodec, Model } form '@heduapp/book-objects-db'
const dbCodec = new DBCodec();
// Encoder can return either inserted ContentGroup or ContentLeaf
const insertedBook = (await dbCodec.encode(book)) as Model.ContentGroup;
await insertedBook.$loadRelated('[children.[contentLeafs.[locale], locale], locale]');

Migrations

  • Apply the latest migration
npx cross-env NODE_ENV=development knex --knexfile src/knexfile.ts --cwd ./ migrate:latest
  • Rollback all migrations
npx knex --knexfile src/knexfile.ts --cwd ./ migrate:rollback
  • Create new migration
  • Migration file is created in migrations/ directory
npx knex --knexfile src/knexfile.ts --cwd ./ migrate:make migration_name

Seed

  • Insert necessary data into the database (locales, etc...)
npx knex --knexfile src/knexfile.ts --cwd ./ seed:run
  • Create new seed
npx knex --knexfile src/knexfile.ts --cwd ./ seed:make xxx-seed_name

Copying remote databases to local

  • Create a pgpass config file
    • On unix based systems: ~/.pgpass
    • On Windows %APPDATA%\postgresql\pgpass.conf
    • Add database logins and passwords, one per line
      hostname:port:database:username:password
    • The config should look something like the following:
      localhost:5433:h_edu_sro1252:h_edu_sro1252:password
      localhost:5432:bo-dev:bo:bo
  • Create an SSH tunnel to H-Edu content service (Back Office will work as well) server
    ssh -L 5433:store4.rosti.cz:5432 -p 14364 [email protected]
  • Run scripts/copy-db.sh
    ./scripts/copy-db.sh [remote-db-name] [local-db-name]
    • With no arguments, the script will clone h_edu_sro1252@localhost:5433 to bo-dev@localhost:5432
    • It will drop the target database
    • It will create a .backup file in the current working directory, and name it like remote-db-name_2019-01-10-16-48-19.backup

Contributing

Running dev DB

Start the containers:

docker-compose -f docker/db-dev.yml up -d

Stop the containers:

docker-compose -f docker/db-dev.yml down
  • Exposed ports:
    • 8080 Adminer for managing the DB
    • 3306 MySQL
  • Database: bo-dev
  • Credentials:
    • User: bo
    • Password: bo
  • Root credentials:
    • User: root
    • Password: root

Tests

Alsatian is used as a testing framework and test runner. To run tests:

npm run test
npm run test-watch

Code style

Code style is enforced by prettier To prettify code:

npm run prettier
npm run prettier-watch

Before pushing to master

  • [ ] Are all tests passing?
  • [ ] Have you ran prettier?

Release new version

git checkout dist
git merge master # Resolve conflicts, accepting changes from master
npm run build
git add --all
git commit -m "Add vX.X.X build"
npm version major|minor|patch # Should be same as the version in the commit message
git push origin dist