1.2.0 • Published 3 years ago

cress v1.2.0

Weekly downloads
6
License
ISC
Repository
-
Last release
3 years ago

# Cress

Cress aggregates commonly used packages across projects and just re-exports them so that you don't need to install a dozen packages

on every new project.

Installing

yarn add cress

Docs

  1. moment
  2. uuid
  3. Apollo

Criteria Objects

Many functions use criteria objects to build a query WHERE clause. A criteria object is a JavaScript map matching database fields to values. Unless otherwise specified in the field name, the predicate operation is assumed to be equality. Massive's query builder is extremely flexible and accommodates both standard and Postgres-specific predicates, including JSON object traversal and array and regexp operations.

{
  'field': 'value',               // equality
  'field <>': 'value',            // inequality
  'field': [1, 2, 3],             // IN (x, y, z) tests
  'field >': 1,                   // greater than
  'field <=': 1,                  // less than or equal
  'field BETWEEN': [1, 100],      // BETWEEN
  'field LIKE': 'val%',           // LIKE
  'field NOT ILIKE': 'Val%',      // NOT LIKE (case-insensitive)
  'field ~': 'val[ue]+',          // regexp match
  'field !~*': 'Val[ue]+',        // no regexp match (case-insensitive)
  'field @>': ['value', 'Value'], // array contains
  'field.arr[1].item': 'value'    // JSON traversal
}

Query Options

Some functions, particularly the query functions (find, findOne, findDoc, search, and searchDoc) allow usage of an options object as the second argument. Like the criteria object, this is an ordinary JavaScript map; however, the field names are fixed. Any field may be omitted if not needed. The options object may be omitted entirely if not needed.

{ build: true, // return query text and parameters without executing anything document: true, // treat table as a document store (see 'Documents') fields: 'name', 'created_at' // retrieve only the specified fields (can be used with exprs) exprs: { // retrieve the specified expressions (can be used with fields) lowername: 'lower(name)' } order: [{ // creates an ORDER BY clause to enforce sorting field: 'settings.role', // JSON fields use . and [] notation direction: 'desc', // set the sort direction with 'desc' or 'asc' (optional) type: 'int' // enforce a cast type (optional) }, { field: 'name' // order elements are applied in order }], orderBody: true, // order applies to document body fields instead of table columns offset: 20, // adds an OFFSET to skip the first n rows limit: 10, // adds a LIMIT to restrict the number of rows returned single: true, // return the first result row as an object instead of all rows stream: true, // return results as a readable stream (see below) only: true // ignore tables inheriting from the target table }

1.2.0

3 years ago

8.0.3

3 years ago

8.0.2

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

6.0.1

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.0.0

3 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

1.0.0

3 years ago