+exemplate, +fields

This commit is contained in:
Simon Martens
2026-01-07 16:43:35 +01:00
parent 02d78388e7
commit f9fb077518
13 changed files with 897 additions and 272 deletions

View File

@@ -1,6 +1,7 @@
package dbmodels
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/core"
)
@@ -186,6 +187,17 @@ func Contents_Entry(app core.App, id string) ([]*Content, error) {
)
}
func Items_Entry(app core.App, id string) ([]*Item, error) {
var ret []*Item
err := app.RecordQuery(ITEMS_TABLE).
Where(dbx.NewExp(
ENTRIES_TABLE+" = {:id} OR (json_valid("+ENTRIES_TABLE+") = 1 AND EXISTS (SELECT 1 FROM json_each("+ENTRIES_TABLE+") WHERE value = {:id}))",
dbx.Params{"id": id},
)).
All(&ret)
return ret, err
}
func Contents_MusenalmID(app core.App, id string) (*Content, error) {
ret, err := TableByField[Content](app, CONTENTS_TABLE, MUSENALMID_FIELD, id)
return &ret, err