github pocketbase/pocketbase v0.17.0
v0.17.0 Release

latest releases: v0.22.15, v0.22.14, v0.22.14-rc...
11 months ago

⚠️ Make sure to have a backup of your pb_data before updating if you are not using the update command with the prebuilt executable.

  • New more detailed guides for using PocketBase as framework (both Go and JS).
    If you find any typos or issues with the docs please report them in https://github.com/pocketbase/site.

  • Added new experimental JavaScript app hooks binding via goja.
    They are available by default with the prebuilt executable if you create *.pb.js file(s) in the pb_hooks directory.
    Lower your expectations because the integration comes with some limitations. For more details please check the Extend with JavaScript guide.
    Optionally, you can also enable the JS app hooks as part of a custom Go build for dynamic scripting but you need to register the jsvm plugin manually:

    jsvm.MustRegister(app core.App, config jsvm.Config{})
  • Added Instagram OAuth2 provider (#2534; thanks @pnmcosta).

  • Added VK OAuth2 provider (#2533; thanks @imperatrona).

  • Added Yandex OAuth2 provider (#2762; thanks @imperatrona).

  • Added new fields to core.ServeEvent:

    type ServeEvent struct {
      App    App
      Router *echo.Echo
      // new fields
      Server      *http.Server      // allows adjusting the HTTP server config (global timeouts, TLS options, etc.)
      CertManager *autocert.Manager // allows adjusting the autocert options (cache dir, host policy, etc.)
    }
  • Added record.ExpandedOne(rel) and record.ExpandedAll(rel) helpers to retrieve casted single or multiple expand relations from the already loaded "expand" Record data.

  • Added rule and filter record Dao helpers:

    app.Dao().FindRecordsByFilter("posts", "title ~ 'lorem ipsum' && visible = true", "-created", 10)
    app.Dao().FindFirstRecordByFilter("posts", "slug='test' && active=true")
    app.Dao().CanAccessRecord(record, requestInfo, rule)
  • Added Dao.WithoutHooks() helper to create a new Dao from the current one but without the create/update/delete hooks.

  • Use a default fetch function that will return all relations in case the fetchFunc argument of Dao.ExpandRecord(record, expands, fetchFunc) and Dao.ExpandRecords(records, expands, fetchFunc) is nil.

  • For convenience it is now possible to call Dao.RecordQuery(collectionModelOrIdentifier) with just the collection id or name.
    In case an invalid collection id/name string is passed the query will be resolved with cancelled context error.

  • Refactored apis.ApiError validation errors serialization to allow map[string]error and map[string]any when generating the public safe formatted ApiError.Data.

  • Added support for wrapped API errors (in case Go 1.20+ is used with multiple wrapped errors, the first apis.ApiError takes precedence).

  • Added ?download=1 file query parameter to the file serving endpoint to force the browser to always download the file and not show its preview.

  • Added new utility github.com/pocketbase/pocketbase/tools/template subpackage to assist with rendering HTML templates using the standard Go html/template and text/template syntax.

  • Added types.JsonMap.Get(k) and types.JsonMap.Set(k, v) helpers for the cases where the type aliased direct map access is not allowed (eg. in goja).

  • Soft-deprecated security.NewToken() in favor of security.NewJWT().

  • Hook.Add() and Hook.PreAdd now returns a unique string identifier that could be used to remove the registered hook handler via Hook.Remove(handlerId).

  • Changed the after* hooks to be called right before writing the user response, allowing users to return response errors from the after hooks.
    There is also no longer need for returning explicitly hook.StopPropagtion when writing custom response body in a hook because we will skip the finalizer response body write if a response was already "committed".

  • ⚠️ Renamed *Options{} to Config{} for consistency and replaced the unnecessary pointers with their value equivalent to keep the applied configuration defaults isolated within their function calls:

    old: pocketbase.NewWithConfig(config *pocketbase.Config) *pocketbase.PocketBase
    new: pocketbase.NewWithConfig(config pocketbase.Config) *pocketbase.PocketBase
    
    old: core.NewBaseApp(config *core.BaseAppConfig) *core.BaseApp
    new: core.NewBaseApp(config core.BaseAppConfig) *core.BaseApp
    
    old: apis.Serve(app core.App, options *apis.ServeOptions) error
    new: apis.Serve(app core.App, config apis.ServeConfig) (*http.Server, error)
    
    old: jsvm.MustRegisterMigrations(app core.App, options *jsvm.MigrationsOptions)
    new: jsvm.MustRegister(app core.App, config jsvm.Config)
    
    old: ghupdate.MustRegister(app core.App, rootCmd *cobra.Command, options *ghupdate.Options)
    new: ghupdate.MustRegister(app core.App, rootCmd *cobra.Command, config ghupdate.Config)
    
    old: migratecmd.MustRegister(app core.App, rootCmd *cobra.Command, options *migratecmd.Options)
    new: migratecmd.MustRegister(app core.App, rootCmd *cobra.Command, config migratecmd.Config)
  • ⚠️ Changed the type of subscriptions.Message.Data from string to []byte because Data usually is a json bytes slice anyway.

  • ⚠️ Renamed models.RequestData to models.RequestInfo and soft-deprecated apis.RequestData(c) in favor of apis.RequestInfo(c) to avoid the stuttering with the Data field.
    The old apis.RequestData() method still works to minimize the breaking changes but it is recommended to replace it with apis.RequestInfo(c).

  • ⚠️ Changes to the List/Search APIs

    • Added new query parameter ?skipTotal=1 to skip the COUNT query performed with the list/search actions (#2965).
      If ?skipTotal=1 is set, the response fields totalItems and totalPages will have -1 value (this is to avoid having different JSON responses and to differentiate from the zero default).
      With the latest JS SDK 0.16+ and Dart SDK v0.11+ versions skipTotal=1 is set by default for the getFirstListItem() and getFullList() requests.

    • The count and regular select statements also now executes concurrently, meaning that we no longer perform normalization over the page parameter and in case the user
      request a page that doesn't exist (eg. ?page=99999999) we'll return empty items array.

    • Reverted the default COUNT column to id as there are some common situations where it can negatively impact the query performance.
      Additionally, from this version we also set PRAGMA temp_store = MEMORY so that also helps with the temp B-TREE creation when id is used.
      There are still scenarios where COUNT queries with rowid executes faster, but the majority of the time when nested relations lookups are used it seems to have the opposite effect (at least based on the benchmarks dataset).

  • ⚠️ Disallowed relations to views from non-view collections (#3000).
    The change was necessary because I wasn't able to find an efficient way to track view changes and the previous behavior could have too many unexpected side-effects (eg. view with computed ids).
    There is a system migration that will convert the existing view relation fields to json (multiple) and text (single) fields.
    This could be a breaking change if you have relation to view and use expand or some of the relation view fields as part of a collection rule.

  • ⚠️ Added an extra action argument to the Dao hooks to allow skipping the default persist behavior.
    In preparation for the logs generalization, the Dao.After*Func methods now also allow returning an error.

  • Allowed 0 as RelationOptions.MinSelect value to avoid the ambiguity between 0 and non-filled input value (#2817).

  • Fixed zero-default value not being used if the field is not explicitly set when manually creating records (#2992).
    Additionally, record.Get(field) will now always return normalized value (the same as in the json serialization) for consistency and to avoid ambiguities with what is stored in the related DB table.
    The schema fields columns DEFAULT definition was also updated for new collections to ensure that NULL values can't be accidentally inserted.

  • Fixed migrate down not returning the correct lastAppliedMigrations() when the stored migration applied time is in seconds.

  • Fixed realtime delete event to be called after the record was deleted from the DB (including transactions and cascade delete operations).

  • Other minor fixes and improvements (typos and grammar fixes, updated dependencies, removed unnecessary 404 error check in the Admin UI, etc.).

Don't miss a new pocketbase release

NewReleases is sending notifications on new releases.