emptyInstance

Full name: taxi.stdlib.emptyInstance

Signature

declare extension function <A> emptyInstance(instanceType:lang.taxi.Type<A>): A

Description

Returns an instance of the requested type with all fields set to their empty state: scalars are null, collections are [], and nested objects are recursively emptied.

// Create a blank template of a type
find {
   blank: MyModel = emptyInstance(MyModel)
}

Examples

Creates an empty instance of a model: scalars are null and collections are empty arrays.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed
Next
Welcome to Taxi