MaravelQL Features
1. Create resource
only with allowed fields
2. Read/Get resource
also with relations, appends, count relations and exist relations
3. Update/Upsert/Increment resource
only with allowed fields (or create if not found, if (pk) incrementing = false or by custom condition if the identifier is other than the pk)
also with relations, appends, count relations and exist relations
supports incrementing for the summable columns ONLY. Use "++x[.xx]" or "--x[.xx]". Incrementing can be made together with other updates. Incrementing is possible only on existing resource.
4. Delete resource
only if allowed
5. Bulk delete resource
only if coded using $service->list({Controlled filters})->delete();
not built-in
6. List resource
list resource /resource?...
list the resource's relation (as a resource) /resource/{pk}/{relationName}?...
list response as JSON or JSONL
controlled via request header application/json and limit=-1
multi sorting on the resource's columns and on its aggregations and default sort
in header query for GET requests or POST requests for filtering with sensitive data
to avoid 499 http code in access logs and DB block via api call, the DB select statements are restricted with a timeout for mysql >= 5.7.4 and mariadb >= 10.1.1
aggregations (including on the FILTERED relations' columns)
sums,
averages,
minimums,
maximums,
distinct column(s) fetching (including custom sql: 'distinct COALESCE(NULLIF({table}.column, ""), {table}.column2) as column)',
group by (columns of the resource plus relation counts and date cast able columns, but if index required on filtering is enabled then first group by column MUST be indexed and not casted; if distincts are used then group by is disregarded),
sub totals,
sub averages,
sub minimums,
sub maximums,
count distinct,
group count,
count relations,
exist relations,
havings (including relation counts, group counts, count distincts, sums, averages, minimums, maximums),
filters for resource and relations:
from (inclusive),
to (inclusive),
in,
not in,
starts with,
is null (inluding also (column in (...) OR column IS NULL) condition),
is not null,
contains (not fulltext search),
notContains,
pagination (LengthAwarePaginator as default or Paginator or CursorPaginator)
page,
limit, // limit=0 for count only without pages
simplePaginate (request response without total count)
cursor
conditions on relations
with/without relations,
with appends, (need custom coding)
with distinct (columns from) relations,
has relations,
has distinct relations,
doesn't have relations,
relations OPTIMIZED filters (except morph relations),
custom NEW relations
HasManySelfThroughSelf,
HasManyThrough2LinkTables,
HasManyThrough3LinkTables,
HasOneSelfThroughSelf,
HasOneThrough2LinkTables,
HasOneThrough3LinkTables,
MVCC DB "select count(*) from table" slow query solution in MySql >= 8
In worst case scenario will estimate the count rather than execute the count without index filter
Prevent DB blocking via API with long running queries for mysql >= 5.7.4 and mariaDB >= 10.1.1
retroactive working StreamedJsonResponse laravel/framework#55509
7. Composite primary key
using user defined separator (default _): 12_35
8. Sql debugging/logging
9. Error handling/logging
10. Datetime NOT timestamp for created_at and updated_at columns
11. Autocomplete on model properties
Also if autocomplete is needed on the model itself, then @ mixin can be added on the model:
Putting @ property on the model is less effective as opposed to this new Attribute class because of the public properties from eloquent model. Also it will avoid polluting the autocomplete with functions and properties from Eloquent model.
12. Read-only DTO for model
13. Prevent updates to model
- download as csv via stream without saving the file on server,
- renames/maps the column names for the resource and its relations,
- can also compose additional columns from the resource columns and from its relations' columns,
- can restrict the number of columns returned to the requested ones, including in the csv download as stream,
- flattens the resource with its relations into a single table,
- eases the filtering on the relations' columns by transforming them into filters by the resource's column in regards to the url query string,
- offers resource AND relations' column aggregations
- can update the one to one relations on resource update
- all json string values are parsed by htmlspecialchars function on decoration
