1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-03-21 22:49:42 +02:00

updated collection db methods godoc

This commit is contained in:
Gani Georgiev 2024-12-12 23:01:01 +02:00
parent 8e63e81561
commit 20d378cd76
2 changed files with 9 additions and 9 deletions

@ -369,7 +369,7 @@ type App interface {
// - If you are updating a Collection in a transaction and then call this method before commit, // - If you are updating a Collection in a transaction and then call this method before commit,
// it'll return the cached Collection state and not the one from the uncommitted transaction. // it'll return the cached Collection state and not the one from the uncommitted transaction.
// - The cache is automatically updated on collections db change (create/update/delete). // - The cache is automatically updated on collections db change (create/update/delete).
// To manually reload the cache you can call [App.ReloadCachedCollections()] // To manually reload the cache you can call [App.ReloadCachedCollections]
FindCachedCollectionByNameOrId(nameOrId string) (*Collection, error) FindCachedCollectionByNameOrId(nameOrId string) (*Collection, error)
// FindCollectionReferences returns information for all relation // FindCollectionReferences returns information for all relation
@ -396,7 +396,7 @@ type App interface {
// - If you are updating a Collection in a transaction and then call this method before commit, // - If you are updating a Collection in a transaction and then call this method before commit,
// it'll return the cached Collection state and not the one from the uncommitted transaction. // it'll return the cached Collection state and not the one from the uncommitted transaction.
// - The cache is automatically updated on collections db change (create/update/delete). // - The cache is automatically updated on collections db change (create/update/delete).
// To manually reload the cache you can call [App.ReloadCachedCollections()]. // To manually reload the cache you can call [App.ReloadCachedCollections].
FindCachedCollectionReferences(collection *Collection, excludeIds ...string) (map[*Collection][]Field, error) FindCachedCollectionReferences(collection *Collection, excludeIds ...string) (map[*Collection][]Field, error)
// IsCollectionNameUnique checks that there is no existing collection // IsCollectionNameUnique checks that there is no existing collection

@ -76,16 +76,16 @@ func (app *BaseApp) FindCollectionByNameOrId(nameOrId string) (*Collection, erro
return m, nil return m, nil
} }
// FindCachedCollectionByNameOrId is similar to [App.FindCollectionByNameOrId] // FindCachedCollectionByNameOrId is similar to [BaseApp.FindCollectionByNameOrId]
// but retrieves the Collection from the app cache instead of making a db call. // but retrieves the Collection from the app cache instead of making a db call.
// //
// NB! This method is suitable for read-only Collection operations. // NB! This method is suitable for read-only Collection operations.
// //
// Returns [sql.ErrNoRows] if no Collection is found for consistency // Returns [sql.ErrNoRows] if no Collection is found for consistency
// with the [App.FindCollectionByNameOrId] method. // with the [BaseApp.FindCollectionByNameOrId] method.
// //
// If you plan making changes to the returned Collection model, // If you plan making changes to the returned Collection model,
// use [App.FindCollectionByNameOrId] instead. // use [BaseApp.FindCollectionByNameOrId] instead.
// //
// Caveats: // Caveats:
// //
@ -95,7 +95,7 @@ func (app *BaseApp) FindCollectionByNameOrId(nameOrId string) (*Collection, erro
// - If you are updating a Collection in a transaction and then call this method before commit, // - If you are updating a Collection in a transaction and then call this method before commit,
// it'll return the cached Collection state and not the one from the uncommitted transaction. // it'll return the cached Collection state and not the one from the uncommitted transaction.
// - The cache is automatically updated on collections db change (create/update/delete). // - The cache is automatically updated on collections db change (create/update/delete).
// To manually reload the cache you can call [App.ReloadCachedCollections()]. // To manually reload the cache you can call [BaseApp.ReloadCachedCollections].
func (app *BaseApp) FindCachedCollectionByNameOrId(nameOrId string) (*Collection, error) { func (app *BaseApp) FindCachedCollectionByNameOrId(nameOrId string) (*Collection, error) {
collections, _ := app.Store().Get(StoreKeyCachedCollections).([]*Collection) collections, _ := app.Store().Get(StoreKeyCachedCollections).([]*Collection)
if collections == nil { if collections == nil {
@ -145,13 +145,13 @@ func (app *BaseApp) FindCollectionReferences(collection *Collection, excludeIds
return result, nil return result, nil
} }
// FindCachedCollectionReferences is similar to [App.FindCollectionReferences] // FindCachedCollectionReferences is similar to [BaseApp.FindCollectionReferences]
// but retrieves the Collection from the app cache instead of making a db call. // but retrieves the Collection from the app cache instead of making a db call.
// //
// NB! This method is suitable for read-only Collection operations. // NB! This method is suitable for read-only Collection operations.
// //
// If you plan making changes to the returned Collection model, // If you plan making changes to the returned Collection model,
// use [App.FindCollectionReferences] instead. // use [BaseApp.FindCollectionReferences] instead.
// //
// Caveats: // Caveats:
// //
@ -161,7 +161,7 @@ func (app *BaseApp) FindCollectionReferences(collection *Collection, excludeIds
// - If you are updating a Collection in a transaction and then call this method before commit, // - If you are updating a Collection in a transaction and then call this method before commit,
// it'll return the cached Collection state and not the one from the uncommitted transaction. // it'll return the cached Collection state and not the one from the uncommitted transaction.
// - The cache is automatically updated on collections db change (create/update/delete). // - The cache is automatically updated on collections db change (create/update/delete).
// To manually reload the cache you can call [App.ReloadCachedCollections()]. // To manually reload the cache you can call [BaseApp.ReloadCachedCollections].
func (app *BaseApp) FindCachedCollectionReferences(collection *Collection, excludeIds ...string) (map[*Collection][]Field, error) { func (app *BaseApp) FindCachedCollectionReferences(collection *Collection, excludeIds ...string) (map[*Collection][]Field, error) {
collections, _ := app.Store().Get(StoreKeyCachedCollections).([]*Collection) collections, _ := app.Store().Get(StoreKeyCachedCollections).([]*Collection)
if collections == nil { if collections == nil {