Skip to content

Commit 57a1041

Browse files
committed
feat: Allow templating of the MongoDB connection URL. (close #295)
1 parent 8e402ca commit 57a1041

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

docs/reference/hooks.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Hooks
22

33
::: tip
4-
Although all are not applicable, [common FeathersJS hooks](https://auk.docs.feathersjs.com/api/hooks-common.html) are exposed in addition to krawler hooks and can be used in jobs, e.g. you can add `disallow: 'external'` to avoid exposing some services when deploying as a web app.
4+
Although all are not applicable, [common FeathersJS hooks](https://auk.docs.feathersjs.com/api/hooks-common.html) are exposed in addition to krawler hooks and can be used in jobs, e.g. you can add `disallow: 'external'` to avoid exposing some services when deploying as a web app.
55
:::
66

77
## Common options
@@ -17,7 +17,7 @@ Due to templating restricted to string output any ISO date string or comparison
1717
Matching is for instance useful when you'd like to apply a hook to only a subset of your tasks, e.g. all the CSV files but not the JSON files.
1818

1919
Fault tolerance is for instance useful when you use unreliable data sources and you don't want the job to stop when some requests fail.
20-
:::
20+
:::
2121

2222
All input/output hooks and store hooks manipulating items, i.e. reading/writing/transforming/removing data in a store like `readJson`, `writeJson` or `gzipToStore`, can have the following options:
2323
* **storePath**: property path where to read the store to be used on the hook object or params, defaults to `data.store`
@@ -180,7 +180,7 @@ Pull a docker image. Hook options are the following:
180180
Run a docker container. Hook options are the following:
181181
* **clientPath**: property path where to retrieve the client object, defaults to `client`
182182
* any options supported by dockerode for [container creation](https://github.com/apocas/dockerode#manipulating-a-container)
183-
183+
184184
::: tip
185185
`Cmd` and `Env` options can be templates, learn more about [templating](https://lodash.com/docs/4.17.4#template)
186186
:::
@@ -190,7 +190,7 @@ Run a docker container. Hook options are the following:
190190
Create a docker service on a Swarm cluster. Hook options are the following:
191191
* **clientPath**: property path where to retrieve the client object, defaults to `client`
192192
* any options supported by dockerode for [service creation](https://github.com/apocas/dockerode#documentation)
193-
193+
194194
::: tip
195195
Options can be templates, learn more about [templating](https://lodash.com/docs/4.17.4#template)
196196
:::
@@ -354,8 +354,8 @@ fetchIMAPMessages: {
354354
mailbox: 'INBOX',
355355
range: { seen: false },
356356
query: { uid: true },
357-
clientPath: 'taskTemplate.imapClient',
358-
dataPath: 'data.messages'
357+
clientPath: 'taskTemplate.imapClient',
358+
dataPath: 'data.messages'
359359
}
360360
```
361361
### downloadIMAPAttachments
@@ -558,12 +558,12 @@ Read a KML from an input stream/store and convert it to in-memory JSON values, h
558558
### connectMongo(options)
559559

560560
Connect to a MongoDB database. The [connection options](http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#.connect) of the client are defined in the hook options plus:
561-
* **url**: MongoDB [URI connection string](https://docs.mongodb.com/manual/reference/connection-string/)
561+
* **url**: MongoDB [URI connection string](https://docs.mongodb.com/manual/reference/connection-string/). This field can be a template with item as context, learn more about [templating](https://lodash.com/docs/4.17.4#template)
562562
* **dbName**: the name of the DB to connect to
563563
* **clientPath**: property path where to store the client object to be used by the MongoDB hooks, defaults to `client`
564564

565565
::: tip
566-
Since **Krawler** relies on the version 3.1.13 of the MongoDB driver, it automatically adds the option `useNewUrlParser: true` when connecting to the database.
566+
Since **Krawler** relies on the version 3.1.13 of the MongoDB driver, it automatically adds the option `useNewUrlParser: true` when connecting to the database.
567567
:::
568568

569569
### disconnectMongo(options)
@@ -625,7 +625,7 @@ Inserts JSON into an existing collection (uses [insertOne](https://docs.mongodb.
625625
* **clientPath**: property path where to retrieve the client object, defaults to `client`
626626
* **transform**: perform transformation using these options before write, see description in [transformJson](./hooks.md#transformjson-options)
627627
* any option supported by `options` argument of the [bulkWrite](https://docs.mongodb.com/manual/reference/method/db.collection.bulkWrite/) function.
628-
628+
629629
::: tip
630630
If the input data is a GeoJSON collection the array of features will be pushed into the collection not the root object, this is to conform with MongoDB geospatial capabilities that can not handle recursive collections.
631631
:::
@@ -642,7 +642,7 @@ Updates JSON into an existing collection (uses [updateOne](https://docs.mongodb.
642642
* **filter/upsert/hint**: corresponding option for `updateOne` operation, filter fields can be templates, learn more about [templating](https://lodash.com/docs/4.17.4#template)
643643
* **excludedProperties**: array of property names to be excluded from automated type conversion after templating, useful if you have a number-like string (eg '81') that you don't want to convert automatically into a number
644644
* any option supported by `options` argument of the [bulkWrite](https://docs.mongodb.com/manual/reference/method/db.collection.bulkWrite/) function.
645-
645+
646646
::: tip
647647
If the input data is a GeoJSON collection the array of features will be updated into the collection not the root object, this is to conform with MongoDB geospatial capabilities that can not handle recursive collections.
648648
:::
@@ -669,7 +669,7 @@ Creates an [aggregation pipeline](https://docs.mongodb.com/manual/aggregation/#a
669669
* **skipAllConvert** allows to skip all conversions
670670
* other options are passed as is
671671
* any option supported by `options` argument of the [aggregate](https://docs.mongodb.com/manual/reference/method/db.collection.aggregate/) function.
672-
672+
673673
::: tip
674674
If the input data is a GeoJSON collection the array of features will be pushed into the collection not the root object, this is to conform with MongoDB geospatial capabilities that can not handle recursive collections.
675675
:::
@@ -719,7 +719,7 @@ Connect to a Feathers API. The [connection options](https://docs.feathersjs.com/
719719
* **clientPath**: property path where to store the client object to be used by the Feathers hooks, defaults to `client`
720720

721721
::: tip
722-
**Krawler** uses the version 5 of the Feathers client.
722+
**Krawler** uses the version 5 of the Feathers client.
723723
:::
724724

725725
### disconnectFeathers(options)
@@ -809,7 +809,7 @@ Also, this hook allows you to use the same environment variables as [node-postgr
809809
* `PGPORT=5432`
810810
* `PGDATABASE=database`
811811

812-
Finaly and for some security reason, it is highly recommended to combine both ways such as in the following example:
812+
Finaly and for some security reason, it is highly recommended to combine both ways such as in the following example:
813813
```
814814
connectPG: {
815815
user: process.env.PG_USER,
@@ -950,7 +950,7 @@ Untar files or directories using [node-tar](https://github.com/npm/node-tar), ho
950950

951951
Run a system command. Hook options are the following:
952952
* **command**: the template of the command to be run with the hook object as context (could be an array commands for a sequence)
953-
* **spawn**: `true` to use `child_process.spawn` instead of `child_process.exec` (default) to run the command(s), in that case a command is given as an array of args instead of a single string
953+
* **spawn**: `true` to use `child_process.spawn` instead of `child_process.exec` (default) to run the command(s), in that case a command is given as an array of args instead of a single string
954954
* **stdout**: boolean indicating if stdout is logged and stored in the hook object
955955
* **stderr**: boolean indicating if stderr is logged and stored in the hook object
956956

0 commit comments

Comments
 (0)