Skip to content

Commit

Permalink
documentation improvements
Browse files Browse the repository at this point in the history
removed unused code

added coverage doc

renamed ci workflow
  • Loading branch information
LaravelFreelancerNL committed Aug 31, 2020
1 parent 4a2a7fc commit 3dc5b0e
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: CI tests

on: [workflow_dispatch, push, pull_request]

Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ The generated AQL for this query is:
FOR i IN 1..100 FILTER i < 50 LIMIT 10 SORT i DESC RETURN i
```

## API
See the following pages on details for the API

- API
- [Query clauses](docs/api/query-clauses.md): how to search, select, sort and limit data
- [Statement clauses](docs/api/statement-clauses.md): data manipulation & variable declaration
- [Graph clauses](docs/api/graph-clauses.md): graph traversals
- [Functions](docs/api/functions.md): a list of all supported AQL functions
- [Subqueries](docs/core-concepts/subqueries.md): how to create subqueries, joins etc.

### (Always) bind user input
No matter what, never trust user input and always bind it.
```
Expand All @@ -113,6 +103,18 @@ Binds are registered in order and given an id. If you want to specify the bind n
$qb->bind('your data', 'your-bind-id')
```

## Documentation
- API
- [Query clauses](docs/api/query-clauses.md): how to search, select, sort and limit data
- [Statement clauses](docs/api/statement-clauses.md): data manipulation & variable declaration
- [Graph clauses](docs/api/graph-clauses.md): graph traversals
- [Functions](docs/api/functions.md): a list of all supported AQL functions
- [Subqueries](docs/core-concepts/subqueries.md): how to create subqueries, joins etc.
- Core Concepts
- [Terminology](docs/core-concepts/terminology.md): definitions of terms used in the documentation
- [Data binding](docs/core-concepts/data-binding.md): How to inject external data and collections
- [Subqueries](docs/core-concepts/subqueries.md): Subquery creation

## References & resources

### ArangoDB
Expand Down
44 changes: 23 additions & 21 deletions docs/api/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This page gives an overview of the AQL functions supported by this query builder
If you are missing a function please create an issue requesting it. In the meantime you can use the raw clause.

## Using functions
Functions always return expressions to be used in clauses and other functions.
Functions always return expressions to be used in clauses or other expressions.

Example:
```
Expand All @@ -17,44 +17,46 @@ $qb->for('i', '1..100')
->return('i');
```


## Array functions

| Description | AQL Function |
| :-------------------- | :-------------------------------------------------------------------------------------------- |
| count($value) | [COUNT()](https://www.arangodb.com/docs/stable/aql/functions-array.html#count) |
| countDistinct($value) | [COUNT_DISTINCT()](https://www.arangodb.com/docs/stable/aql/functions-array.html#count) |
| first($value) | [FIRST()](https://www.arangodb.com/docs/stable/aql/functions-array.html#first) |
| last($value) | [LAST()](https://www.arangodb.com/docs/stable/aql/functions-array.html#last) |
| length($value) | [LENGTH()](https://www.arangodb.com/docs/stable/aql/functions-array.html#length) |
| count($value) | [COUNT(anyArray)](https://www.arangodb.com/docs/stable/aql/functions-array.html#count) |
| countDistinct($value) | [COUNT_DISTINCT(anyArray)](https://www.arangodb.com/docs/stable/aql/functions-array.html#count) |
| first($value) | [FIRST(anyArray)](https://www.arangodb.com/docs/stable/aql/functions-array.html#first) |
| last($value) | [LAST(anyArray)](https://www.arangodb.com/docs/stable/aql/functions-array.html#last) |
| length($value) | [LENGTH(anyArray)](https://www.arangodb.com/docs/stable/aql/functions-array.html#length) |


## Date functions

| Description | AQL Function |
| :-------------------- | :-------------------------------------------------------------------------------------------- |
| dateNow() | [DATE_NOW()](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_now) |
| dateIso8601(numeric&#124;string&#124;DateTime $date) | [DATE_ISO8601(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_iso8601) |
| dateTimestamp(numeric&#124;string&#124;DateTime $date) | [DATE_TIMESTAMP(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_timestamp) |
| | []() |
| | []() |
| | []() |
| | []() |
| dateYear($date) | [DATE_YEAR(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_year) |
| dateMonth($date) | [DATE_MONTH(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_month) |
| dateDay($date) | [DATE_DAY(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_day) |
| dateHour($date) | [DATE_HOUR(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_hour) |
| dateMinute($date) | [DATE_MINUTE(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_minute) |
| dateSecond($date) | [DATE_SECOND(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_second) |
| dateMillisecond($date) | [DATE_MILLISECOND(date)](https://www.arangodb.com/docs/stable/aql/functions-date.html#date_millisecond) |

## GEO functions

| Description | AQL Function |
| :-------------------- | :-------------------------------------------------------------------------------------------- |
| distance($latitude1, $longitude1, $latitude2, $longitude2) | [DISTANCE(latitude1, longitude1, latitude2, longitude2)](https://www.arangodb.com/docs/stable/aql/functions-geo.html#distance) |

## Miscellaneous functions

| Description | AQL Function |
| :-------------------- | :-------------------------------------------------------------------------------------------- |
| document($collection, $id = null) | [DOCUMENT(collection, id)](https://www.arangodb.com/docs/stable/aql/functions-miscellaneous.html#document) |
| average($value) | []() |
| avg($value) | []() |
| max($value) | []() |
| min($value) | []() |
| rand() | []() |
| sum($value) | []() |

## Numeric functions
| Description | AQL Function |
| :-------------------- | :-------------------------------------------------------------------------------------------- |
| average($value) | [AVERAGE(numArray](https://www.arangodb.com/docs/stable/aql/functions-numeric.html#average) |
| avg($value) | [AVG(numArray](https://www.arangodb.com/docs/stable/aql/functions-numeric.html#average) |
| max($value) | [MAX(anyArray)](https://www.arangodb.com/docs/stable/aql/functions-numeric.html#max) |
| min($value) | [MIN(anyArray)](https://www.arangodb.com/docs/stable/aql/functions-numeric.html#min) |
| rand() | [RAND()](https://www.arangodb.com/docs/stable/aql/functions-numeric.html#rand) |
| sum($value) | [SUM(numArray)](https://www.arangodb.com/docs/stable/aql/functions-numeric.html#sum) |
33 changes: 33 additions & 0 deletions docs/core-concepts/data-binding.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# Data binding
```
bind($data, $to = null)
```
Inject data through the bind command.

**Example 1:**
```
$qb->filter('u.age', '==', $qb->bind(18));
```
Resulting AQL: `FILTER u.age == @{a_generated_id}`

**Example 2 - with bind id:**
```
$qb->filter('u.age', '==', $qb->bind(18, 'my_bind'));
```
Resulting AQL: `FILTER u.age == @my_bind`

## Bind collection names
```
bindCollection($data, $to = null)
```
Inject collection names through the bindCollection command.

**Example 1:**
```
$qb->for('user', $qb->bindCollection('users'));
```
Resulting AQL: `FOR user IN @@{a_generated_id}`

**Example 2 - with bind id:**
```
$qb->for('user', $qb->bindCollection('users', 'collectionBind'));
```
Resulting AQL: `FOR user IN @@collectionBind`

4 changes: 2 additions & 2 deletions docs/core-concepts/subqueries.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Subqueries
You can easily create subqueries by passing one query bulder object to another as an expression.
You can easily create subqueries by passing one query builder object to another as an expression.

Example:
```
Expand All @@ -9,7 +9,7 @@ Example:
->return('u._key')
->get();
$result = (new QueryBuilder())
$mainQuery = (new QueryBuilder())
->for('u', 'users')
->filter('u._key', '==', $subQuery)
->return('u')
Expand Down
5 changes: 0 additions & 5 deletions src/Traits/NormalizesExpressions.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ protected function determineArgumentType($argument, $allowedExpressionTypes = nu
}
}

//Fallback to BindExpression if allowed
if (isset($allowedExpressionTypes['Bind'])) {
return 'Bind';
}

throw new ExpressionTypeException(
"This argument,
'{$argument}', does not match one of these expression types: "
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/AQL/DateFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* @covers \LaravelFreelancerNL\FluentAQL\AQL\HasDateFunctions
* @covers \LaravelFreelancerNL\FluentAQL\Traits\NormalizesDateFunctions
* @covers \LaravelFreelancerNL\FluentAQL\Traits\NormalizesFunctions
*/
class DateFunctionsTest extends TestCase
{
Expand Down

0 comments on commit 3dc5b0e

Please sign in to comment.