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

fragments-postgres

v1.0.0-beta.11

Published

postgres for fragments: migration commands, auto generated mesa tables, data accessor functions and more

Downloads

13

Readme

fragments-postgres

the documentation in this readme is work in progress and currently unfinished !

BETA NPM Package Build Status codecov.io Dependencies Downloads per Month

postgres for fragments: migration commands, auto generated mesa tables, data accessor functions and more

you should probably first read what fragments is all about !

also see fragments-user as an example app that uses fragments-postgres extensively.

just add fragments-postgres as a source to your fragments application. for example like this:

#!/usr/bin/env node

var hinoki = require('hinoki');
var fragments = require('fragments');
var fragmentsPostgres = require('fragments-postgres');

var source = hinoki.source([
  __dirname,
  fragments.source,
  fragments.umgebung,
  fragmentsPostgres
]);

source = hinoki.decorateSourceToAlsoLookupWithPrefix(source, 'fragments_');

module.exports = fragments(source);

if (require.main === module) {
  module.exports.runCommand();
}

migration commands

migrations:create {migration-name} - create a new migration in directory that is in envvar `MIGRATION_PATH`
pg:create - create database whose name is in envvar `POSTGRES_DATABASE`
pg:drop - drop database whose name is in envvar `POSTGRES_DATABASE`
pg:drop-create - drop and then create database whose name is in in envvar `POSTGRES_DATABASE`
pg:drop-create-migrate - drop and then create database whose name is in in envvar `POSTGRES_DATABASE` and then apply all migrations in directory that is in envvar `MIGRATION_PATH` to database whose url is in envvar `DATABASE_URL`
pg:migrate [--verbose] [--dry] - migrate: apply all migrations in directory that is in envvar `MIGRATION_PATH` to database whose url is in envvar `DATABASE_URL`

mesa

key mesa maps to a mesa object that connects to the database reachable under envvar DATABASE_URL using a connection pool of size envvar POSTGRES_POOL_SIZE.

auto generated mesa tables

key userTable maps to a mesa object that is made from mesa above to use table user: mesa.table('user'). urlSnapshotTable uses table url_snapshot: mesa.table('url_snapshot'). you get the idea.

auto generated data accessor functions

key firstUserWhereId maps to a function which returns a promise that will resolve to the first record from table user where column id matches the argument id in the database reachable under envvar DATABASE_URL. it runs the following mesa query: userTable.where({id: id}).first(). use any table name or column name. chain multiple where clauses.

selectUrlSnapshotWhereIsDead(false) returns a promise that will resolve to all records from table url_snapshot where column is_dead is false. it runs the following mesa query: urlSnapshotTable.where({is_dead: false}).select(). use any table name or column name. chain multiple where clauses.

deleteUserWhereId(id) works as expected. it runs the following mesa query: userTable.where({id: id}).delete(). use any table name or column name. chain multiple where clauses. at least one where clause is required for delete.

if you need more complex queries use the mesa tables directly.

license: MIT