0.55.8 • Published 2 months ago

@startupjs/server-aggregate v0.55.8

Weekly downloads
314
License
-
Repository
-
Last release
2 months 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.56.0-alpha.53

2 months ago

0.56.0-alpha.0

4 months ago

0.55.7

5 months ago

0.55.8

5 months ago

0.55.0-alpha.1

7 months ago

0.55.0

6 months ago

0.53.0

9 months ago

0.55.0-alpha.12

6 months ago

0.54.1

7 months ago

0.54.0

7 months ago

0.51.0

12 months ago

0.52.1

12 months ago

0.52.0

12 months ago

0.50.13

1 year ago

0.50.12

1 year ago

0.50.5

1 year ago

0.48.0

2 years ago

0.49.0

1 year ago

0.47.0

2 years ago

0.46.0

2 years ago

0.45.0

2 years ago

0.44.0

2 years ago

0.42.0

2 years ago

0.43.0

2 years ago

0.41.2

2 years ago

0.41.0

2 years ago

0.42.6

2 years ago

0.43.1

2 years ago

0.39.11

3 years ago

0.40.0

3 years ago

0.39.0

3 years ago

0.38.0

3 years ago

0.37.0

3 years ago

0.36.0

3 years ago

0.35.10

3 years ago

0.35.2

3 years ago

0.35.0

3 years ago

0.34.0

3 years ago

0.33.0

3 years ago

0.33.0-alpha.0

3 years ago

0.32.9

3 years ago

0.32.8

3 years ago

0.32.1

3 years ago

0.32.0

3 years ago

0.31.26

3 years ago

0.31.25

3 years ago

0.31.0

3 years ago

0.30.9

3 years ago

0.30.7

3 years ago

0.30.6

3 years ago

0.30.5

3 years ago

0.30.4

3 years ago

0.30.3

3 years ago

0.30.2

3 years ago

0.30.1

3 years ago

0.30.0

3 years ago

0.29.2

3 years ago