querycraft-pipelines
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

QueryCraft-Pipelines

Database agnostic formulation for data pipelines

NPM

npm version codecov Known Vulnerabilities

Installation

npm install --save 'querycraft-pipelines'

Examples

Suppose we have a collection of data that satisfies the interface

interface contact {
    id: string
    'list': { id: string }[]
    firstName: string
    lastName: string
    email: string
    createdAt: Date
    customFields: { id: string, value: number }[]
    assignedTo?: string
}

If we want an aggregations the describes the logic:-


    where
        fistName is bob
        lastName is doyle OR is not set
        assignedTo is anything
        list has an item where id is item1
    Group by
        the value property of the customField where id is custom1

We can build build it as easily as:-

import { FilterBuilder, eq, lt, neq, any, find, where } from 'querycraft'
import { Pipeline } from 'querycraft-pipelines'

const contacts: contact[] =  [ ... ]

const pipeline = new Pipeline()
.filter(
    where('firstName', eq('bob'))
    .where('list', find(where('id', eq('item1'))))
    .where('lastName', any([
        eq('doyle'),
        eq(null)
    ]))
    .where('createdAt', lt({ daysAgo: 5 }))
    .where('assignedTo', neq(null))
)
.buckets({
    fieldId: 'CustomFields',
    subFieldIds: ['custom1'],
    subFieldProp: 'value',
})

/querycraft-pipelines/

    Package Sidebar

    Install

    npm i querycraft-pipelines

    Weekly Downloads

    0

    Version

    0.0.9

    License

    MIT

    Unpacked Size

    2.13 MB

    Total Files

    22

    Last publish

    Collaborators

    • ahmadassaf
    • dayoadeyemi
    • beamery_hq