Discover Packages
github.com/arllen133/sqlc
examples
02_relationships
models
package
Version:
v0.4.0
Opens a new window with list of versions in this module.
Published: Feb 26, 2026
License: MIT
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
type Post struct {
ID int64 `db:"id,primaryKey,autoIncrement"`
UserID int64 `db:"user_id"`
Title string `db:"title"`
Author *User `db:"-" relation:"belongsTo,foreignKey:user_id"`
}
Post belongs to User
type User struct {
ID int64 `db:"id,primaryKey,autoIncrement"`
Name string `db:"name"`
Posts []*Post `db:"-" relation:"hasMany,foreignKey:user_id"`
}
User has many Posts
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.