0.55.8 • Published 1 year ago

@startupjs/server-aggregate v0.55.8

Weekly downloads
314
License
-
Repository
-
Last release
1 year ago

@startupjs/server-aggregate

Racer server aggregate plugin. It allows only server-defined aggregate queries.

install

yarn add @startupjs/server-aggregate

requirements

racer: 0.9.15

usage

In our client code:

require('@startupjs/server-aggregate/client')

On the server:

const serverAggregate = require('@startupjs/server-aggregate')
serverAggregate(backend, customCheck)

Here:

- `backend` - your backend
- `customCheck` - your personal check function. It should return an error message if there is an error. **IMPORTANT** The message must be of type `string`.

// function addAggregate accept
// 'collection' - collection name
// 'queryName'  - name of query
// 'cb' - function that accepts 'params' and 'shareRequest'
// and returns a query-object or error-string

backend.addAggregate('items', 'main', async (params, shareRequest) => {
  // ...
  // access control or whatever
  // ...

  return [
    {$match: {type: 'wooden'}}
  ]
})

Using queries (on the client):

  // function aggregateQuery accepts 3 arguments:
  // 'collection' - collection name (should match one from addServerQuery)
  // 'queryName' - name of query (should match one from addServerQuery)
  // 'params' - object with query-params

  const query = model.aggregateQuery('items', 'main', {
    type: 'global'
  })

  model.subscribe(query, function(){
    // ...
  })

Alternative approach (using regular model.query)

  const query = model.query('items', {
    $aggregationName: 'main',
    $params: {
      type: 'global'
    }
  })

  model.subscribe(query, function(){
    // ...
  })

MIT License

Copyright (c) 2018 by Artur Zayats

0.57.0-canary.0

1 year ago

0.56.0-alpha.53

1 year ago

0.56.0-alpha.0

1 year ago

0.55.7

1 year ago

0.55.8

1 year ago

0.55.0-alpha.1

2 years ago

0.55.0

2 years ago

0.53.0

2 years ago

0.55.0-alpha.12

2 years ago

0.54.1

2 years ago

0.54.0

2 years ago

0.51.0

2 years ago

0.52.1

2 years ago

0.52.0

2 years ago

0.50.13

2 years ago

0.50.12

2 years ago

0.50.5

2 years ago

0.48.0

3 years ago

0.49.0

3 years ago

0.47.0

3 years ago

0.46.0

3 years ago

0.45.0

3 years ago

0.44.0

3 years ago

0.42.0

3 years ago

0.43.0

3 years ago

0.41.2

3 years ago

0.41.0

3 years ago

0.42.6

3 years ago

0.43.1

3 years ago

0.39.11

4 years ago

0.40.0

4 years ago

0.39.0

4 years ago

0.38.0

4 years ago

0.37.0

4 years ago

0.36.0

4 years ago

0.35.10

4 years ago

0.35.2

4 years ago

0.35.0

4 years ago

0.34.0

4 years ago

0.33.0

4 years ago

0.33.0-alpha.0

4 years ago

0.32.9

4 years ago

0.32.8

4 years ago

0.32.1

4 years ago

0.32.0

4 years ago

0.31.26

4 years ago

0.31.25

4 years ago

0.31.0

4 years ago

0.30.9

4 years ago

0.30.7

4 years ago

0.30.6

4 years ago

0.30.5

4 years ago

0.30.4

4 years ago

0.30.3

4 years ago

0.30.2

4 years ago

0.30.1

4 years ago

0.30.0

4 years ago

0.29.2

5 years ago