example

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package example is the reference schema for momo: a multi-tenant document store with comments, tags and a pgvector embedding. Copy it as a starting point. Run `go generate ./...` after changing a model; `momo generate --check` fails CI when the committed output is stale.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	momo.Model `momo:"table:comments"`
	ID         int64 `momo:"pk,identity"`
	DocumentID int64 `momo:"index"`
	Body       string
}

Comment is a remark on a document.

func (*Comment) MomoMeta

func (*Comment) MomoMeta() *momo.Meta[Comment]

type Document

type Document struct {
	momo.Model `momo:"table:documents"`
	ID         int64         `momo:"pk,identity"`
	TenantID   int64         `momo:"column:tenant_id,notnull,index"`
	Title      string        `momo:"size:300,notnull"`
	Body       string        `momo:"type:text"`
	Embedding  vector.Vector `momo:"dim:1536"`
	Status     string        `momo:"column:status,enum:document_status,default:'draft'"`
	CreatedAt  time.Time     `momo:"column:created_at,read_only,default:now()"`

	Comments []Comment `momo:"has_many,fk:DocumentID"`
	Tags     []Tag     `momo:"many2many,join:document_tags"`
	Tenant   *Tenant   `momo:"belongs_to,fk:TenantID"`
}

Document is a tenant's document with a semantic-search embedding.

func (*Document) MomoConfig

func (d *Document) MomoConfig(c *momo.Config)

MomoConfig declares what struct tags cannot express: the hnsw index with its operator class (hnsw has no default), the status enum, a check and a comment. The generator reads it statically; it never runs.

func (*Document) MomoMeta

func (*Document) MomoMeta() *momo.Meta[Document]

type Tag

type Tag struct {
	momo.Model `momo:"table:tags"`
	ID         int64  `momo:"pk,identity"`
	Name       string `momo:"unique"`
}

Tag labels documents through the document_tags join table.

func (*Tag) MomoMeta

func (*Tag) MomoMeta() *momo.Meta[Tag]

type Tenant

type Tenant struct {
	momo.Model `momo:"table:tenants"`
	ID         int64  `momo:"pk,identity"`
	Name       string `momo:"size:200,notnull,unique"`
}

Tenant owns documents.

func (*Tenant) MomoMeta

func (*Tenant) MomoMeta() *momo.Meta[Tenant]

Directories

Path Synopsis
Package comment holds typed column descriptors and relation descriptors for the Comment model.
Package comment holds typed column descriptors and relation descriptors for the Comment model.
Package document holds typed column descriptors and relation descriptors for the Document model.
Package document holds typed column descriptors and relation descriptors for the Document model.
Package tag holds typed column descriptors and relation descriptors for the Tag model.
Package tag holds typed column descriptors and relation descriptors for the Tag model.
Package tenant holds typed column descriptors and relation descriptors for the Tenant model.
Package tenant holds typed column descriptors and relation descriptors for the Tenant model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL