Noun
Named entities and concepts in your domain
Noun
Nouns represent the named entities and concepts in your domain - the "things" you're working with.
Context is Everything
Every Noun exists within a Domain namespace - and that namespace IS the $context. When you define a Noun, you're not just creating a schema - you're teaching AI what this concept means in YOUR domain:
// In the acme.do namespace/context
const Customer = Noun('Customer', {
name: 'string',
tier: ['free', 'pro', 'enterprise'],
})
// AI now understands what "Customer" means at acme.do
// - semantically (JSON-LD @context)
// - cognitively (how to reason about customers)The same word "Customer" means different things in different domains. The namespace provides the context that disambiguates meaning for both machines and AI.
Overview
In the primitives framework, a Noun is a type definition for domain entities. Nouns define the schema for Things - the actual instances that exist in your system.
import { Noun } from 'ai-database'
// Define a noun (type/schema)
const Customer = Noun('Customer', {
name: 'string',
email: 'string',
tier: ['free', 'pro', 'enterprise'],
})
// Create a thing (instance)
const customer = Customer.create({
name: 'Acme Corp',
email: 'hello@acme.com',
tier: 'pro',
})Defining Nouns
Nouns are defined with a name and a schema:
import { Noun } from 'ai-database'
const Invoice = Noun('Invoice', {
number: 'string',
amount: 'number',
status: ['draft', 'sent', 'paid', 'overdue'],
dueDate: 'Date',
})AI-Inferred Nouns
Nouns can be inferred from natural language:
import { Noun } from 'ai-database'
// AI infers the schema from the description
const Product = Noun('Product', `
A product in our catalog with a name, description,
price, and inventory count. Products belong to categories
and can have multiple variants.
`)Relationships
Nouns can define relationships to other nouns:
const Order = Noun('Order', {
number: 'string',
customer: Customer, // belongs to Customer
items: [OrderItem], // has many OrderItems
status: ['pending', 'processing', 'shipped', 'delivered'],
})See Also
- Domain - The namespace that IS the context
- Thing - Instances of nouns
- Verb - Actions that operate on nouns
- Database - Storage and querying of nouns and things