object

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package object Object Expression Operators

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeObjects

func MergeObjects[T expression.DocumentExpression](e []T) objectOperator

MergeObjects Combines multiple documents into a single document. $mergeObjects is available in these stages: $bucket $bucketAuto $group When used as a $bucket, $bucketAuto, or $group stage accumulator, $mergeObjects has this syntax: { $mergeObjects: <document> } When used in other expressions (including in $bucket, $bucketAuto, and $group stages) but not as an accumulator, $mergeObjects has this syntax: { $mergeObjects: [ <document1>, <document2>, ... ] } The <document> can be any valid expression that resolves to a document.

func ObjectToArray

func ObjectToArray[T expression.DocumentExpression](e T) objectOperator

ObjectToArray Converts a document to an array. The return array contains an element for each field/value pair in the original document. Each element in the return array is a document that contains two fields k and v: The k field contains the field name in the original document. The v field contains the value of the field in the original document. $objectToArray has the following syntax: { $objectToArray: <object> } The <object> expression can be any valid expression as long as it resolves to a document object. $objectToArray applies to the top-level fields of its argument. If the argument is a document that itself contains embedded document fields, the $objectToArray does not recursively apply to the embedded document fields.

func SetField

func SetField[T expression.AnyExpression, O expression.ObjectExpression](field string, input O, value T) objectOperator

SetField New in version 5.0. Adds, updates, or removes a specified field in a document. You can use $setField to add, update, or remove fields with names that contain periods (.) or start with dollar signs ($). $setField has the following syntax:

{
 $setField: {
   field: <String>,
   input: <Object>,
   value: <Expression>
 }
}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL