mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-19 14:17:48 +02:00
removed unnecessary collection queries
This commit is contained in:
parent
71a70bac9d
commit
624b443f98
@ -211,12 +211,7 @@ func (dao *Dao) FindRecordsByIds(
|
|||||||
// expr2 := dbx.NewExp("LOWER(username) = {:username}", dbx.Params{"username": "test"})
|
// expr2 := dbx.NewExp("LOWER(username) = {:username}", dbx.Params{"username": "test"})
|
||||||
// dao.FindRecordsByExpr("example", expr1, expr2)
|
// dao.FindRecordsByExpr("example", expr1, expr2)
|
||||||
func (dao *Dao) FindRecordsByExpr(collectionNameOrId string, exprs ...dbx.Expression) ([]*models.Record, error) {
|
func (dao *Dao) FindRecordsByExpr(collectionNameOrId string, exprs ...dbx.Expression) ([]*models.Record, error) {
|
||||||
collection, err := dao.FindCollectionByNameOrId(collectionNameOrId)
|
query := dao.RecordQuery(collectionNameOrId)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
query := dao.RecordQuery(collection)
|
|
||||||
|
|
||||||
// add only the non-nil expressions
|
// add only the non-nil expressions
|
||||||
for _, expr := range exprs {
|
for _, expr := range exprs {
|
||||||
@ -241,14 +236,9 @@ func (dao *Dao) FindFirstRecordByData(
|
|||||||
key string,
|
key string,
|
||||||
value any,
|
value any,
|
||||||
) (*models.Record, error) {
|
) (*models.Record, error) {
|
||||||
collection, err := dao.FindCollectionByNameOrId(collectionNameOrId)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
record := &models.Record{}
|
record := &models.Record{}
|
||||||
|
|
||||||
err = dao.RecordQuery(collection).
|
err := dao.RecordQuery(collectionNameOrId).
|
||||||
AndWhere(dbx.HashExp{inflector.Columnify(key): value}).
|
AndWhere(dbx.HashExp{inflector.Columnify(key): value}).
|
||||||
Limit(1).
|
Limit(1).
|
||||||
One(record)
|
One(record)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user