Customers
Customer registration, address book management, order history
Customers
For customer login, registration with password, token management, and password reset, see Customer Authentication.
Create Customer (Server)
Use ServerClient to create customer records directly:
const customer = await client.from('customers').create({
name: 'John Doe',
email: 'john@example.com',
phone: '010-1234-5678'
})email and phone are indexed per tenant for fast lookups.
Lookup Customer
// Find by email
const { docs } = await client.from('customers').find({
where: { email: { equals: 'john@example.com' } }
})Address Book
Store multiple shipping addresses per customer with default address support.
// Add address
await client.from('customer-addresses').create({
customer: customerId,
label: 'Home',
recipientName: 'John Doe',
phone: '010-1234-5678',
postalCode: '06123',
address1: '123 Main St',
address2: 'Apt 4B',
isDefault: true
})
// Get default address
const { docs } = await client.from('customer-addresses').find({
where: {
customer: { equals: customerId },
isDefault: { equals: true }
}
})
// All addresses
const { docs: addresses } = await client.from('customer-addresses').find({
where: { customer: { equals: customerId } }
})Order History
// Customer's order history
const { docs: orders } = await client.from('orders').find({
where: { customer: { equals: customerId } },
sort: '-createdAt'
})Collection Reference
For detailed field specifications, see Customer Collections.