Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions definitions/expression/replaceOne.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ arguments:
- resolvesToString
- resolvesToNull
description: |
The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null.
The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceOne returns null.
- name: find
type:
- resolvesToString
- resolvesToNull
- resolvesToRegex
description: |
The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null.
The string or regex to search for within the given input. Can be any valid expression that resolves to a string, a regex, or a null. If find refers to a field that is missing, $replaceOne returns null.
- name: replacement
type:
- resolvesToString
- resolvesToNull
description: |
The string to use to replace all matched instances of find in input. Can be any valid expression that resolves to a string or a null.
The string to use to replace the first matched instance of find in input. Can be any valid expression that resolves to a string or a null.
tests:
- name: Example
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/#example
Expand All @@ -44,3 +45,20 @@ tests:
item:
types:
- bsonType: String
- name: Replace Using Regex
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/#replace-using-regex
pipeline:
- $project:
item:
$replaceOne:
input: $item
find: !bson_regex '\bblue paint\b'
replacement: red paint
schema:
inventory:
_id:
types:
- bsonType: Number
item:
types:
- bsonType: String
Loading