models

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 models is the schema of the quickstart: authors and their posts, each post carrying an embedding for similarity search.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

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

	Posts []Post `momo:"has_many,fk:AuthorID"`
}

Author writes posts.

func (*Author) MomoMeta

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

type Post

type Post struct {
	momo.Model `momo:"table:posts"`
	ID         int64         `momo:"pk,identity"`
	AuthorID   int64         `momo:"column:author_id,notnull,index"`
	Title      string        `momo:"size:300,notnull"`
	Embedding  vector.Vector `momo:"dim:3"`
	CreatedAt  time.Time     `momo:"column:created_at,read_only,default:now()"`

	Author *Author `momo:"belongs_to,fk:AuthorID"`
}

Post is one article with a 3-dimensional embedding. Real embeddings are larger: change dim to the output size of your model, for example 1536.

func (*Post) MomoConfig

func (p *Post) MomoConfig(c *momo.Config)

MomoConfig declares what struct tags cannot express. pgvector's hnsw method has no default operator class, so name it. The generator reads this method statically; it never runs.

func (*Post) MomoMeta

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

Directories

Path Synopsis
Package author holds typed column descriptors and relation descriptors for the Author model.
Package author holds typed column descriptors and relation descriptors for the Author model.
Package post holds typed column descriptors and relation descriptors for the Post model.
Package post holds typed column descriptors and relation descriptors for the Post model.

Jump to

Keyboard shortcuts

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