65 Commits

Author SHA1 Message Date
Ben Steel
2bf247fc6c
chore(docs): Update resolvers.md (#2954) 2023-01-01 20:55:22 -08:00
Marshall Thompson
3b5d2c9afd
chore(docs): Use deep outline for Typebox sidebar (#2950) 2023-01-01 13:18:54 -08:00
Sebastian Große
d93fe4e24a
chore(docs): Minor typo fix in generator.md (#2952) 2022-12-26 15:25:37 -08:00
Marshall Thompson
5e52593e02
chore(docs): Add pre-release banner (#2946) 2022-12-20 17:20:45 -08:00
David Luecke
b15fa7db49
chore(docs): Add Google analytics and Netlify configuration (#2935) 2022-12-20 13:02:30 -08:00
David Luecke
f324940d57
feat(schema): Allow to add additional operators to the query syntax (#2941) 2022-12-20 08:26:14 -08:00
Marshall Thompson
9ea9e5d98f
chore(docs): Enable offline search, no Algolia (#2942) 2022-12-19 23:05:58 -08:00
Marshall Thompson
0d43245365
chore: Update Algolia config for docs (#2937) 2022-12-19 22:38:14 -08:00
David Luecke
a443673ff6
chore(docs): Add @pre flag to all installation commands (#2940) 2022-12-18 16:36:50 -08:00
David Luecke
04156541ae
chore(docs): Add documentation how to extend database adapters (#2939) 2022-12-18 13:39:58 -08:00
Ashot Nazaryan
59c3b8d2a5
chore(docs): Add note about methods option (#2925) 2022-12-14 14:43:56 -08:00
David Luecke
7088af64a5
feat(cli): Use separate patch schema and types (#2916) 2022-12-14 11:18:46 -08:00
fratzinger
d606ac660f
fix(core): context.type for around hooks (#2890) 2022-12-09 09:46:09 -08:00
Marshall Thompson
142914fc00
feat(docs): CLI and application structure guide (#2818) 2022-12-08 11:55:18 -08:00
David Luecke
9f712bf569
chore(dependencies): Update all dependencies (#2901) 2022-12-06 11:54:13 -08:00
David Luecke
9ddc2e6b02
feat(adapter): Add patch data type to adapters and refactor AdapterBase usage (#2906) 2022-12-05 22:06:41 -08:00
David Luecke
7d03b57ae2
feat(schema): Virtual property resolvers (#2900) 2022-12-03 10:05:11 -08:00
David Luecke
4822c94981
feat(schema): Split resolver options and property resolvers (#2889) 2022-11-23 17:04:37 -08:00
David Luecke
59f3cdca63
fix(typebox): Improve query syntax defaults (#2888) 2022-11-23 17:04:28 -08:00
David Luecke
82ba2d1494
docs(faq): Update FAQ entries for v5 (#2883) 2022-11-23 17:04:17 -08:00
David Luecke
bddce89079
chore(tests): Fix Express application test (#2891) 2022-11-23 16:43:53 -08:00
Marshall Thompson
c901e8f1d9
chore(docs): Finalize home page copy (#2882) 2022-11-18 21:44:43 -08:00
Marshall Thompson
11ccaa19e6
docs(typebox): explain extended ajv configuration (#2881) 2022-11-18 15:48:58 -07:00
fratzinger
8f8088d9ca
docs(awesome): Use query-string url for search filters (#2843) 2022-11-18 13:49:23 -08:00
Marshall Thompson
7fa2012897
fix(cli): mongodb connection string for node 17+ (#2875) 2022-11-18 13:48:25 -08:00
Marshall Thompson
0b7b7ba952
docs(typo): fix variable name in query resolver 2022-11-15 09:24:37 -07:00
Marshall Thompson
7bb44ecf0f
docs(typebox): document string formats and custom options 2022-11-14 00:08:24 -07:00
Marshall Thompson
f8bb525a5d
docs(mongodb): update examples to latest CLI code 2022-11-14 00:08:24 -07:00
Marshall Thompson
212847b277
docs(typebox): add descriptions for all types (#2873) 2022-11-11 15:05:40 -07:00
Marshall Thompson
ca063040c3
docs(typebox): fix code examples for union 2022-11-11 11:16:50 -07:00
Marshall Thompson
f6f6b26abc
docs(config): fix branch name for “edit this page” link 2022-11-10 18:58:34 -07:00
Marshall Thompson
2b89e0b7fc
docs(theme): use slots instead of prepend hack (#2858) 2022-11-08 16:26:20 -07:00
Marshall Thompson
0249791571
docs(home): animate the sun and moon (#2865) 2022-11-05 23:46:04 -06:00
Marshall Thompson
24187bb138
docs(home): smoother transition from night to day (#2864) 2022-11-05 17:35:16 -06:00
Marshall Thompson
4f188fee93
docs(theme): show DatabaseSelect on all pages (#2863) 2022-11-05 17:24:34 -06:00
Marshall Thompson
911ababe2f
docs(home): Fine-tune the SVGs, transitions, layout (#2862) 2022-11-05 16:29:18 -06:00
Marshall Thompson
d1e458ecb9
chore(docs) typo (#2860) 2022-11-05 12:27:27 -06:00
Marshall Thompson
a6b2623b74
chore(docs) fix ecosystem page ssr mismatch (#2859)
Wraps the `Packages` component in a `ClientOnly` component
2022-11-05 12:25:58 -06:00
Marshall Thompson
a26fef65ba
docs(ecosystem) rename awesome to ecosystem (#2854) 2022-11-05 11:45:03 -06:00
Marshall Thompson
742e5b8256
docs(styles): Fix home footer (#2855) 2022-11-04 22:58:45 -07:00
David Luecke
c5c1fba571
feat(mongodb): Add ObjectId resolvers and MongoDB option in the guide (#2847) 2022-11-04 21:10:58 -07:00
Marshall Thompson
9bf5222c15
docs(styles): Fix responsive styles (#2852) 2022-11-04 16:29:08 -07:00
Marshall Thompson
cb70e0778e
feat(mongodb) aggregation pipeline queries (#2840)
* feat(mongodb) aggregation pipeline queries

Makes queries using the MongoDB Aggregation Pipeline, by default, unless either of these conditions is met:

- `params.mongodb` is provided. This object is for the `collection.find` method, and won’t work for `collection.aggregate`.
- `params.query.$limit` is set to `0`. The aggregation pipeline will not accept 0 as a value for the `$limit` stage.

## Updates to `service.find`

The `find` method has been updated so that queries not meeting the two criteria, above, are created using the aggregation pipeline, which is an array of the document objects representing the stages of the request. Here’s an example query:

```ts
app.service(‘todos’).find({
  query: {
    $sort: { name: 1 },
    $skip: 1,
    $limit: 4
  }
})

// the internal aggregation request looks like this
const query = collection.aggregate([
  { $match: {} },
  { $sort: { name: 1 } },
  { $skip: 1 },
  { $limit: 4 },
  …params.pipeline || []
])
```

## New `pipeline` param

Notice that it’s now possible to pass `params.pipeline`.  This means you can set params.pipeline as an array of additional stages in the aggregation pipeline and they will be executed during the same request.  This means that it’s now possible to perform `$lookup` and `$unwind` stages alongside the normal Feathers queries.

## Feathers Query with `params.pipeline`

This example shows how to populate the `user` onto a query for `todos`, assuming that each `todo` contains a `userId` property.

```ts
const result = await app.service('todos').find({
  query: { $sort: { name: 1 } },
  pipeline: [
    {
      $lookup: {
        from: ‘users’,
        localField: 'userId',
        foreignField: '_id',
        as: ‘user’
      }
    },
    { $unwind: { path: '$user’ } }
  ],
  paginate: false
})
```

In the above example, the `query` is added to the pipeline, first (under the hood) then additional stages are added in the `pipeline` option:

- The `$lookup` stage creates an array called `user` which contains any matches in `todo.userId`, so if `userId` were an array of ids, any matches would be in the `users` array.  However, in this example, the `userId` is a single id, so…
- The `$unwind` stage turns the array into a single object.

All stages of the pipeline happen directly on the MongoDB server.

## Custom `.aggregate` requests

It’s still possible to make `.aggregate` requests without the Feathers syntax by directly accessing `service.model`:

```ts
const result = await app.service(‘todos’).model.aggregate([
   // …stages go here
]).toArray()
```

* refactor(mongodb): decouple find logic, getModel

Splits the `find` method into two utilities for converting params into MongoDB requests:

- `asFindQuery`
- `asAggregateQuery`

Each of the above methods returns the raw MongoDB request object, without having called `.toArray`, so it’s likely also possible to directly use MongoDB cursors on the returned object, though I’ve not added a test for such a use case.

This PR also optimizes the `find` method to parallelize the `count` query (for pagination) and the `results` query.  This makes it so we don’t have to wait for the count before we start querying the results.

One more thing: this PR also combines non-DRY code that was found in every method into a single `getModel` method.

* feat(mongodb) control stages with $feathers stage

A custom `$feathers` stage has been added to our wrapper for the MongoDB aggregation pipeline.  It allows you to specify where in the pipeline the Feathers-related stages get injected.  This means you can now specify for some pipeline operations to run BEFORE the ones related to the Feathers query.

The `$feathers` stage is an object optionally containing a `handleStages` function.  The `handleStages` function receives the Feathers stages and allows them to be modified.  It’s a feature that will only be used in complex, modular/layered queries, since it would usually be simpler to just modify the incoming query before passing it to `service.find`.

* refactor(mongodb) rename utils and combine methods

- rename `asFindQuery` to `findRaw`
- rename `asAggregateQuery` to `aggregateRaw`
- combine the `makePipeline` method into the `aggregateRaw` method,

* docs(mongodb) document aggregation queries

* feat(mongodb) remove handleStages from aggregation
2022-11-04 15:58:35 -06:00
Marshall Thompson
fe47d3d744
docs(sitemap) create sitemap.xml during build (#2851)
Also splits out `nav` and `sidebar` sections of the config into their own files.
2022-11-04 15:58:01 -06:00
Marshall Thompson
aad223ebb2
chore(docs): Document TypeBox options by type (#2849) 2022-11-04 08:54:37 -07:00
Marshall Thompson
f7fb699d31
chore(docs): Show db selector on basics guide (#2848) 2022-11-04 08:50:51 -07:00
Marshall Thompson
65d36656f5
feat(schema): Add StringEnum to TypeBox module (#2827) 2022-11-03 11:50:04 -07:00
David Luecke
8b89c8bab5
chore(dependencies): Update all dependencies (#2841) 2022-11-03 11:49:33 -07:00
fratzinger
ec94421ea3
chore(docs): Fix search awesome (#2842) 2022-11-01 14:40:36 -07:00
fratzinger
f66177ded1
feat(docs): Add Awesome Ecosystem page 2022-11-01 11:18:31 -07:00