package collection import ( "fmt" "git.nutfactory.org/hoernschen/ActivityPub/utils/database" ) func CreateCollectionObject(collectionId string, objectId string) (err error) { sqlStmt := fmt.Sprintf(`INSERT INTO collectionObject (collectionId, objectId) VALUES (?, ?)`) tx, err := database.DB.Begin() if err != nil { return } stmt, err := tx.Prepare(sqlStmt) if err != nil { return } defer stmt.Close() _, err = stmt.Exec( collectionId, objectId, ) if err != nil { tx.Rollback() return } tx.Commit() return } func ReadCollectionObjects(collectionId string) (collectionObjects []string, err error) { queryStmt := fmt.Sprintf(`SELECT objectId FROM collectionObject WHERE collectionId = '%s'`, collectionId) rows, err := database.DB.Query(queryStmt) if err != nil { return } defer rows.Close() for rows.Next() { var collectionObject string err = rows.Scan( &collectionObject, ) if err != nil { return } collectionObjects = append(collectionObjects, collectionObject) } return }