Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support aggregation methods #28

Closed
KutsenkoA opened this issue Jul 25, 2018 · 1 comment
Closed

Support aggregation methods #28

KutsenkoA opened this issue Jul 25, 2018 · 1 comment
Assignees

Comments

@KutsenkoA
Copy link
Contributor

I'm submitting a ...


[ ] Regression (behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request

Aggregation functions

It would be awesome if SDK had next aggregation functions implemented:

  • count
  • min
  • max
  • avg
  • sum
  • every

Possible syntaxes

There are a few ways to implement this functionality.

1. Simple string

Simplest syntax where aggregators are provided as the strings. Example:

dataset("users")
  .select()
  .fields("max(age)", "isadmin")
  .execute()

Despite the fact that it's an easy to develop and clear solution, it has certain difficulties:

  • no type checking not only for aggregation functions, but alslo this syntax removes field name checking for the fields() method in Typescript.
  • no hints what functions are allowed
  • difficult to extend (for example with aliases)

2. Imported statement

Example:

import aggregation from "jexia-sdk-js";

dataset("users")
  .select()
  .fields(aggregation.max("age"), "isadmin")
  .execute()

This solution looks a little better than previous, but customer has to import additional object. Also it's impossible to add field name checking to aggregation.fn()

3. Object

Example:

dataset("users")
  .select()
  .fields({ fn: "MAX", field: "age" }, "isadmin")
  .execute()

Probably, best solution. Has type checking, hints for function names, easy to extend with additional properties.

KutsenkoA added a commit that referenced this issue Aug 8, 2018
KutsenkoA added a commit that referenced this issue Aug 13, 2018
miss-tique pushed a commit that referenced this issue Aug 13, 2018
<a name="3.5.0"></a>
# [3.5.0](v3.4.0...v3.5.0) (2018-08-13)

### Features

* **query:** aggregation functions support ([38805bb](38805bb)), closes [#28](#28)
@miss-tique
Copy link

🎉 This issue has been resolved in version 3.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants