Skip to main content

Parameters

The createRecords() method object can contain the following properties:

ParameterTypeRequiredDescription
tablestringYesThe name of the target table to insert records into.
dataArray<Record<string, any> & { validation?: Record<string, ValidationRule> }>YesThe array of records to insert. Each record can optionally contain its own validation rules.
optionsCreateRecordsOptionsNoConfiguration flags that control the behaviour of the insertion, validation, and conflict resolution.

Options

OptionTypeDescription
dryRunbooleanIf true, the insertion is simulated. The API returns the wouldCreate or wouldUpdate counts without writing any data.
validationRuleRecord<string, ValidationRule>A single global validation object that applies to all rows. Per-row validation rules can override this.
continueOnErrorbooleanIf true, valid rows are processed and inserted, and the response returns detailed errors for the invalid rows. If false, the entire request fails on the first error.
upsertbooleanIf true, MantaHQ attempts to update matching records instead of creating new ones; otherwise, conflicts are rejected.
conflictKeysstring[]An array of columns (fields) to check for conflicts (for example ['product_id', 'email']).
conflictKeysLogic'and' | 'or'Specifies whether all keys must match (and) or any key must match (or) to determine a conflict.
chunkSizenumberThe number of records to process in a single batch (for future use).
conditionobjectOnly process rows that satisfy this condition (supports and/or and comparison operators).

Validation rules

The validationRule object supports the following constraints:

  • Presence and length: required, minLength, maxLength.
  • Format: format (e.g., email, url, uuid, date, datetime, number, integer, boolean, string).
  • Custom checks: regex, enum.

Supported condition operators

You can use the following friendly syntax operators within the condition object to build complex processing rules. These operators work for the main record condition and for filtering nested records.

OperatorMeaningExample
equalsEqual{ status: { equals:'active' } }
notEqualsNot equal{ status: { notEquals:'inactive' } }
greaterThanGreater than{ age:{ greaterThan:18 } }
greaterOrEqualGreater than or equals{ age:{ greaterOrEqual:18 } }
lessThanLess than{ price:{ lessThan:100 } }
lessOrEqualLess than or equals{ price:{ lessOrEqual:100 } }
inValue is present in the array{ country:{ in:['US','CA'] } }
notInValue is not present in the array{ status:{ notIn:['banned','inactive'] } }
andAll nested conditions must be true{ and:{ age:{>=18}, role:{equals:'admin'} } }
orAt least one nested condition must be true{ or:{ role:{equals:'vip'}, status:{equals:'active'} } }

Conditional creation

The condition object allows you to process a record only if it satisfies specific criteria. This example demonstrates combining and and or logic for precise control over record insertion.

TypeScript
await manta.createRecords({
table: "user",
data: [{ name: "Eve", age: 22, role: "admin", status: "vip" }],
options: {
condition: {
and: {
age: { greaterOrEqual: 18 },
or: { role: { equals: "admin" }, status: { equals: "vip" } },
},
},
},
});
💡Note

In this example, the record is inserted only if the age is 18 or older AND the role is 'admin' OR the status is 'vip'.