GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - imqueue/pg-sequelize: Sequelize/Postgres toolkit for @imqueue microservices — a query described as data becomes one efficient statement

BranchesTags
Open more actions menu

Latest commit

 

History

170 Commits
170 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
scripts
scripts
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.oxfmtrc.json
.oxfmtrc.json
 
 
.oxlintrc.json
.oxlintrc.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
CONTRIBUTION-TERMS.md
CONTRIBUTION-TERMS.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
index.ts
index.ts
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

@imqueue/pg-sequelize

Build Status npm version Known Vulnerabilities License

Turns a query described as data — a filter, a page, an order and the fields the caller actually needs — into one efficient Sequelize statement. Plus database views as models, the Postgres index options Sequelize cannot express, and a single import surface for the whole ORM stack.

Sequelize v6, and the alternative

This targets Sequelize v6 — a mature line, proven in production, and the one this package is actively developed against. Sequelize v7 is still in alpha upstream, so v6 is what there is to build on today; if v7 lands, this follows it.

If you would rather build on Prisma, @imqueue/pg-prisma covers the same ground for that stack. Both are supported — pick the ORM you want to live with.

Renamed

This package was called @imqueue/sequelize up to and including 4.1.3. The old name is deprecated on npm and receives no further releases; there is no compatibility shim. To migrate, change the dependency and every import specifier — no export changed name or signature, and the pg- prefix only states what was always true: this targets Postgres specifically, not every Sequelize dialect.

Install

npm i --save @imqueue/pg-sequelize

Usage

Connect once, anywhere in the service. Every later call hands back the same instance, so only the first one needs the configuration:

import { database, query } from '@imqueue/pg-sequelize';

const sequelize = database({
    logger: console,
    modelsPath: './src/orm/models',
    sequelize: {
        benchmark: true,
        dialect: 'postgres',
        storage: 'sequelize',
        pool: {
            max: 250,
            min: 2,
            idle: 30000,
            acquire: 30000,
        },
    },
});

Then let the caller's own arguments build the query. autoQuery reads the requested field map, so a column nobody asked for is not selected and a relation nobody reached into is not joined:

const where = query.toWhereOptions(query.withRangeFilters(filter));
const rows = await LeadModel.findAll(query.autoQuery<FindOptions>(
    LeadModel,
    fields,
    where,
    query.toLimitOptions(pageOptions),
    query.toOrderOptions(orderBy),
));
const total = await LeadModel.count(query.autoCountQuery(LeadModel, fields, where));

filter, fields, pageOptions and orderBy are plain JSON — FilterInput, FieldsInput, PaginationInput and OrderByInput describe them — because Sequelize writes its operators as ES symbols, and a symbol cannot survive a wire format. A GraphQL resolver is the case this was written against, passing its arguments and its selected field set straight through; an RPC method taking a filter object is the same problem.

Docs

Every exported symbol carries its own documentation, so an editor is the fastest reference. The same content is published, symbol by symbol, as the API reference — searchable, and linkable when you need to point someone at one thing. The wider ecosystem documentation is at imqueue.org. Current version, licence and Node floor for every package: imqueue.org/status.json.

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE

About

Sequelize/Postgres toolkit for @imqueue microservices — a query described as data becomes one efficient statement

imqueue.org

Topics

graphqlimqueueimqueue-ormnodejsormpostgrespostgresqlsequelizetypescript

Resources

Readme
GPL-3.0 license

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

16 stars

Watchers

4 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.