-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* typos Signed-off-by: Thibaut Rousseau <thibaut.rousseau.44@gmail.com> * add mongo executor Signed-off-by: Thibaut Rousseau <thibaut.rousseau.44@gmail.com> * replace __len__ with ShouldHaveLength Signed-off-by: Thibaut Rousseau <thibaut.rousseau.44@gmail.com> * add mongo test stack Signed-off-by: Thibaut Rousseau <thibaut@crew.work> --------- Signed-off-by: Thibaut Rousseau <thibaut.rousseau.44@gmail.com> Signed-off-by: Thibaut Rousseau <thibaut@crew.work>
- Loading branch information
Showing
11 changed files
with
793 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
# Venom - Executor Mongo | ||
|
||
Step to execute actions on a MongoDB database. | ||
|
||
## Input | ||
|
||
See also [tests/mongo.yml](../../tests/mongo.yml) for executable examples. | ||
|
||
Note: most fields support [MongoDB Extended JSON v2](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/). | ||
This means some special values (ObjectIds, ISODates, etc.) can be represented using the relaxed format. | ||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"_id": { | ||
"$oid": "5d505646cf6d4fe581014ab2" | ||
} | ||
} | ||
``` | ||
|
||
### Insert documents | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: insert | ||
documents: | ||
- '{"suit": "hearts", "value": "queen"}' | ||
- '{"suit": "diamonds", "value": "three"}' | ||
``` | ||
### Insert documents from a file | ||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: insert | ||
file: fixtures/my-collection.jsonlist | ||
``` | ||
`fixtures/my-collection.jsonlist`: | ||
|
||
```json | ||
{ | ||
"suit": "hearts", | ||
"value": "queen" | ||
} | ||
{ | ||
"suit": "diamonds", | ||
"value": "three" | ||
} | ||
``` | ||
|
||
### Find documents | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: find | ||
filter: | | ||
{ | ||
"suit": "clubs" | ||
} | ||
options: # optional | ||
limit: 3 | ||
skip: 1 | ||
sort: '{"_id": -1}' | ||
projection: '{"value": 1}' | ||
``` | ||
|
||
### Find documents by ObjectID | ||
|
||
See: [MongoDB Extended JSON - Type Representations](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/#type-representations) | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: find | ||
filter: | | ||
{ | ||
"_id": { | ||
"$oid": "5d505646cf6d4fe581014ab2" | ||
} | ||
} | ||
options: # optional | ||
limit: 3 | ||
skip: 1 | ||
sort: '{"_id": -1}' | ||
projection: '{"value": 1}' | ||
``` | ||
|
||
### Count documents | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: count | ||
filter: | | ||
{ | ||
"suit": "clubs" | ||
} | ||
``` | ||
|
||
### Update documents | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: update | ||
filter: | | ||
{ | ||
"suit": { | ||
"$in": ["clubs", "spades"] | ||
} | ||
} | ||
update: | | ||
{ | ||
"$set": { | ||
"color": "black" | ||
} | ||
} | ||
``` | ||
|
||
### Delete documents | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: delete | ||
filter: | | ||
{ | ||
"suit": "circles" | ||
} | ||
``` | ||
|
||
### Aggregate documents | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: aggregate | ||
pipeline: | ||
- | | ||
{ "$match": { | ||
"color": "black" | ||
}} | ||
- | | ||
{ "$group": { | ||
"_id": "$value", | ||
"count": {"$sum": 1} | ||
}} | ||
``` | ||
|
||
### Create a collection | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: createCollection | ||
``` | ||
|
||
### Drop a collection | ||
|
||
```yaml | ||
- type: mongo | ||
uri: mongodb://localhost:27017 | ||
database: my-database | ||
collection: my-collection | ||
actions: | ||
- type: dropCollection | ||
``` |
Oops, something went wrong.