Cerial
Field Types

String

String field type in Cerial — plain text values for names, descriptions, and any textual content.

The String field type represents plain text. It's the most common field type in Cerial, used for names, descriptions, labels, and any free-form textual content.

Schema Syntax

model User {
  id Record @id
  name String
  bio String?
  title String @default("Untitled")
  tags String[]
}

Types

DirectionType
Outputstring
Inputstring
SurrealDBstring

Create & Update

const user = await client.db.User.create({
  data: {
    name: 'Alice',
    bio: 'Software engineer',
    tags: ['typescript', 'surrealdb'],
  },
});

console.log(user.name);   // 'Alice'
console.log(user.title);  // 'Untitled' (from @default)

// Update
await client.db.User.updateUnique({
  where: { id: user.id },
  data: { bio: 'Senior software engineer' },
});

Filtering

String fields support equality checks, set membership, and substring matching:

// Exact match
const alice = await client.db.User.findMany({
  where: { name: { eq: 'Alice' } },
});

// Substring
const engineers = await client.db.User.findMany({
  where: { bio: { contains: 'engineer' } },
});

// Prefix
const aNames = await client.db.User.findMany({
  where: { name: { startsWith: 'A' } },
});

// Set
const specific = await client.db.User.findMany({
  where: { name: { in: ['Alice', 'Bob', 'Carol'] } },
});

Available Operators

OperatorDescription
eqEqual to
neqNot equal to
inIn a set of values
notInNot in a set of values
containsContains substring
startsWithStarts with prefix
endsWithEnds with suffix

Conditional Operators

OperatorAvailable whenDescription
not? or @nullableNegated comparison
isNone? (optional)true = field is absent
isNull@nullabletrue = field is null
isDefinedAlwaystrue = field exists

OrderBy

String fields support orderBy:

const sorted = await client.db.User.findMany({
  orderBy: { name: 'asc' },
});

In Objects and Tuples

object Address {
  street String
  city String
  zip String
}

tuple FullName {
  first String,
  last String
}

model Contact {
  id Record @id
  address Address
  fullName FullName
}
const contact = await client.db.Contact.create({
  data: {
    address: { street: '123 Main St', city: 'Springfield', zip: '62704' },
    fullName: ['Jane', 'Doe'],
  },
});

contact.address.city;   // 'Springfield'
contact.fullName[0];    // 'Jane'

Arrays

model Article {
  id Record @id
  keywords String[]
  uniqueTags String[] @set
}

String arrays support @set for auto-deduplicated, sorted arrays. They also support @distinct and @sort decorators.

Supported Decorators

DecoratorEffect
@default(value)Default value on create
@defaultAlways(value)Reset to value on every write
@nullableAllow explicit null
@readonlyWrite-once field
@indexDatabase index
@uniqueUnique constraint

On this page