### Install Dependencies Source: https://github.com/pocketbase/site/blob/master/README.md Installs the necessary packages for the project. Run this command before starting the development server. ```sh npm install ``` -------------------------------- ### HTTP Server Setup Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/http.html Provides methods to start an HTTP server and register handlers for specific URL paths. ```APIDOC ## HTTP Server Setup ### Description Provides methods to start an HTTP server and register handlers for specific URL paths. `ListenAndServe` starts a server with a given address and handler (defaults to `DefaultServeMux`). `Handle` and `HandleFunc` add handlers to `DefaultServeMux`. ### Starting a Server ```go http.Handle("/foo", fooHandler) http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) }) log.Fatal(http.ListenAndServe(":8080", nil)) ``` ### Custom Server Configuration For more control, create a custom `Server` instance. ```go s := &http.Server{ Addr: ":8080", Handler: myHandler, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 1 << 20, } log.Fatal(s.ListenAndServe()) ``` ``` -------------------------------- ### start() Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/_app.start.html Starts the application, registering default system commands (serve, superuser, version) and executing pb.RootCmd. ```APIDOC ## start() ### Description Starts the application, registering default system commands (serve, superuser, version) and executing pb.RootCmd. ### Method N/A (This is a function call, not an HTTP endpoint) ### Endpoint N/A ### Returns void ### Source Defined in [types.d.ts:15112](https://github.com/pocketbase/site/blob/d10b615ad/jsvm/types.d.ts#L15112) ``` -------------------------------- ### start Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/pocketbase.PocketBase.html Starts the application by registering default system commands (serve, superuser, version) and executing the root command. ```APIDOC ## start ### Description Starts the application, registering default system commands and executing the root command. ### Method `start()` ### Returns `void` ``` -------------------------------- ### Start PocketBase Web Server Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/apis.serve.html Starts a new app web server. The app must be bootstrapped before calling this function. Configure the HTTP address and whether to display the start banner. ```go app.Bootstrap() apis.Serve(app, apis.ServeConfig{ HttpAddr: "127.0.0.1:8080", ShowStartBanner: false, }) ``` -------------------------------- ### apis.serve Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/apis.serve.html Starts a new app web server. The app must be bootstrapped before starting the web server. ```APIDOC ## apis.serve(app, config) ### Description Starts a new app web server. The app should be bootstrapped before starting the web server. ### Method (Not applicable, this is a function call) ### Parameters #### Parameters - **app**: [excludeHooks](../types/excludeHooks.html)<[App](core.App.html)> - The application instance to serve. - **config**: [ServeConfig](apis.ServeConfig.html) - Configuration object for the server. ### Example ```javascript app.Bootstrap() apis.Serve(app, { HttpAddr: "127.0.0.1:8080", ShowStartBanner: false, }) ``` ### Returns void ``` -------------------------------- ### Registering a GET route with authentication middleware Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/routerAdd.html This example demonstrates how to register a GET route for '/hello' that returns a JSON message and requires authentication using $apis.requireAuth(). Note that this method is only available in the pb_hooks context. ```javascript routerAdd("GET", "/hello", (e) => { return e.json(200, {"message": "Hello!"}) }, $apis.requireAuth()) ``` -------------------------------- ### Add and Start a Cron Job Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/cron.html This snippet demonstrates how to create a new cron instance, add a job with a specific schedule and function, and then start the cron service. Ensure the cron package is imported before use. ```go c := cron.New() c.MustAdd("dailyReport", "0 0 * * *", func() { ... }) c.Start() ``` -------------------------------- ### Starting an HTTP Server with DefaultServeMux Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/http.html ListenAndServe starts an HTTP server. Use Handle and HandleFunc to add handlers to the DefaultServeMux. ```Go http.Handle("/foo", fooHandler) http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) }) log.Fatal(http.ListenAndServe(":8080", nil)) ``` -------------------------------- ### Start Development Server Source: https://github.com/pocketbase/site/blob/master/README.md Starts a local development server with hot reloading enabled. The site will be accessible at localhost:5173. ```sh npm run dev ``` -------------------------------- ### begin Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/dbx.DB.html Starts a transaction and returns a Tx object. ```APIDOC ## begin ### Description Starts a transaction. ### Method begin ### Returns [dbx](../modules/dbx.html).[Tx](dbx.Tx.html) ``` -------------------------------- ### hasExample Source: https://github.com/pocketbase/site/blob/master/static/jsvm/classes/Command.html Determines if the command has example. ```APIDOC ## hasExample ### Description Determines if the command has example. ### Method N/A (Method signature provided) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Returns boolean True if the command has an example, false otherwise. ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### defaultInstallerFunc Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/apis.defaultInstallerFunc.html The default installer function for PocketBase. It opens the installer UI in the browser with a short-lived auth token for the systemSuperuser, allowing users to create their custom superuser record. This function is essential for the initial setup of a PocketBase instance. ```APIDOC ## defaultInstallerFunc(app, systemSuperuser, baseURL) ### Description DefaultInstallerFunc is the default PocketBase installer function. It will attempt to open a link in the browser (with a short-lived auth token for the systemSuperuser) to the installer UI so that users can create their own custom superuser record. See [https://github.com/pocketbase/pocketbase/discussions/5814](https://github.com/pocketbase/pocketbase/discussions/5814). ### Parameters #### Parameters * **app**: [excludeHooks](../types/excludeHooks.html)<[App](core.App.html) angle * **systemSuperuser**: [core](../modules/core.html).[Record](core.Record.html) * **baseURL**: string ### Returns void ``` -------------------------------- ### beginTx Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/dbx.DB.html Starts a transaction with the given context and transaction options. ```APIDOC ## beginTx ### Description Starts a transaction with the given context and transaction options. ### Method beginTx ### Parameters #### Path Parameters - **ctx**: [context](../modules/context.html).[Context](context.Context.html) - Description - **opts**: [TxOptions](sql.TxOptions.html) - Description ### Returns [dbx](../modules/dbx.html).[Tx](dbx.Tx.html) ``` -------------------------------- ### start Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/cron.Cron.html Starts the cron ticker. Calling Start() on an already started cron will restart the ticker. ```APIDOC ## start ### Description Starts the cron ticker. Calling Start() on an already started cron will restart the ticker. ### Method `start` ### Returns void Defined in types.d.ts:20339 ``` -------------------------------- ### Open and Read File Example Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/os.html Demonstrates how to open a file for reading and read a portion of its content. Error handling is shown for the open operation. ```Go file, err := os.Open("file.go") // For read access. if err != nil { log.Fatal(err) } ``` ```Go data := make([]byte, 100) count, err := file.Read(data) if err != nil { log.Fatal(err) } fmt.Printf("read %d bytes: %q\n", count, data[:count]) ``` -------------------------------- ### Starting an HTTP Server with Custom Server Configuration Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/http.html Create a custom http.Server for more control over server behavior, including timeouts and header limits. ```Go s := &http.Server{ Addr: ":8080", Handler: myHandler, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 1 << 20, } log.Fatal(s.ListenAndServe()) ``` -------------------------------- ### start Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/exec.Cmd.html Starts the specified command but does not wait for it to complete. The c.Process field will be set upon successful return. After a successful call, Cmd.Wait must be called to release associated system resources. ```APIDOC ## start() ### Description Starts the specified command but does not wait for it to complete. The c.Process field will be set upon successful return. After a successful call, Cmd.Wait must be called to release associated system resources. ### Method void ### Returns void ``` -------------------------------- ### TCP Client Connection Example Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/net.html Demonstrates how to establish a TCP connection to a server and send an HTTP request. Handles potential connection errors. ```Go conn, err := net.Dial("tcp", "golang.org:80") if err != nil { // handle error } fmt.Fprintf(conn, "GET / HTTP/1.0\r\n\r\n") status, err := bufio.NewReader(conn).ReadString('\n') // ... ``` -------------------------------- ### execute Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/pocketbase.PocketBase.html Initializes the application and executes the root command with graceful shutdown support. It differs from `start()` by not registering default system commands. ```APIDOC ## execute ### Description Executes the application's root command with graceful shutdown support. This method does not register default system commands. ### Method `execute()` ### Returns `void` ``` -------------------------------- ### os.startProcess Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/os.File.html Starts a new process. This function is used to execute external commands or scripts. ```APIDOC ## os.startProcess ### Description Starts a new process. This function is used to execute external commands or scripts. ### Method Not specified (likely a function call within the SDK) ### Endpoint Not applicable (SDK function) ### Parameters Parameters are not explicitly detailed in the provided text. ### Request Example Not applicable (SDK function) ### Response Response details are not explicitly detailed in the provided text. ``` -------------------------------- ### Example Header Parsing Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/http.Request.html Demonstrates how incoming request headers are parsed into a map. Header names are case-insensitive and canonicalized. ```go Header = map[string][]string{ "Accept-Encoding": {"gzip, deflate"}, "Accept-Language": {"en-us"}, "Foo": {"Bar", "two"}, } ``` -------------------------------- ### Example Usage of Context.Done for Cancellation Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/context.Context.html Illustrates how to use the ctx.Done() channel in a select statement to handle context cancellation within a loop. ```go // Stream generates values with DoSomething and sends them to out // until DoSomething returns an error or ctx.Done() is closed. func Stream(ctx context.Context, out chan<- Value) error { for { v, err := DoSomething(ctx) if err != nil { return err } select { case <-ctx.Done(): return ctx.Err() case out <- v: } } } ``` -------------------------------- ### Making HTTP Requests Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/http.html Use Get, Post, and PostForm for basic HTTP or HTTPS requests. Remember to close the response body when finished. ```Go resp, err := http.Get("http://example.com/") ... resp, err := http.Post("http://example.com/upload", "image/jpeg", &buf) ... resp, err := http.PostForm("http://example.com/form", url.Values{"key": {"Value"}, "id": {"123"}}) ``` ```Go resp, err := http.Get("http://example.com/") if err != nil { // handle error } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) // ... ``` -------------------------------- ### Creating and Configuring a Router Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/router.Router.html Demonstrates how to create a new router, bind middleware, define routes, create sub-routers, and finally build an http.ServeMux instance. ```go r := NewRouter[*MyEvent](eventFactory) // middlewares r.BindFunc(m1, m2) // routes r.GET("/test", handler1) // sub-routers/groups api := r.Group("/api") api.GET("/admins", handler2) // generate a http.ServeMux instance based on the router configurations mux, _ := r.BuildMux() http.ListenAndServe("localhost:8090", mux) ``` -------------------------------- ### Get Unsaved Files Example Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.AuthOrigin.html Retrieves unsaved files associated with a specific field key. This allows for pre-persistence modifications like renaming files before they are saved. ```go files := record.GetUnsavedFiles("documents") for _, f := range files { f.Name = "doc_" + f.Name // add a prefix to each file name } app.Save(record) // the files are pointers so the applied changes will transparently reflect on the record value ``` -------------------------------- ### DB.begin Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/sql.DB.html Starts a transaction. The default isolation level is dependent on the driver. This method uses context.Background internally; to specify the context, use DB.BeginTx. ```APIDOC ## DB.begin ### Description Starts a transaction. The default isolation level is dependent on the driver. Begin uses [context.Background] internally; to specify the context, use [DB.BeginTx]. ### Method begin() ### Returns [sql.Tx] ### Defined in types.d.ts:16847 ``` -------------------------------- ### Measuring Elapsed Time with Monotonic Clocks Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/time.html This example demonstrates how to measure elapsed time robustly, even if the system's wall clock is changed. It uses time.Now() to capture both wall and monotonic clock readings and then calculates the difference using t.Sub(start). ```Go start := time.Now() ... operation that takes 20 milliseconds ... t := time.Now() elapsed := t.Sub(start) ``` -------------------------------- ### TCP Server Listen Example Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/net.html Shows how to create a TCP server that listens on a specific port and accepts incoming connections. Each connection is handled in a separate goroutine. ```Go ln, err := net.Listen("tcp", ":8080") if err != nil { // handle error } for { conn, err := ln.Accept() if err != nil { // handle error } go handleConnection(conn) } ``` -------------------------------- ### get Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/router.RouterGroup.html Shorthand for AddRoute with the GET method. Used to define a route that handles GET requests. ```APIDOC ## GET /path ### Description Defines a route that handles GET requests for a given path. ### Method GET ### Endpoint `/path` ### Parameters #### Path Parameters - **path** (string) - Required - The route path. - **action** (function) - Required - The handler function for the route. - **e** (T) - The context object for the request. ### Returns - **Route** - The newly created Route object. ``` -------------------------------- ### beginTx Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/sql.DB.html Starts a new transaction. The provided context is used until the transaction is committed or rolled back. If the context is canceled, the transaction will be rolled back. ```APIDOC ## beginTx(ctx, opts) ### Description Starts a transaction. The provided context is used until the transaction is committed or rolled back. If the context is canceled, the sql package will roll back the transaction. The provided TxOptions is optional and may be nil if defaults should be used. ### Parameters #### Path Parameters - **ctx** (context.Context) - Description of the context for the transaction. - **opts** (sql.TxOptions) - Optional transaction options. If nil, defaults are used. ### Returns - **sql.Tx** - The transaction object. ``` -------------------------------- ### get Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.AuthOrigin.html Get returns a normalized single record model data value for the given key. ```APIDOC ## get(key: string) ### Description Get returns a normalized single record model data value for the given key. ### Parameters #### Path Parameters * **key** (string) - The key of the data value to retrieve. ### Returns * any ### Source Defined in types.d.ts:13206 ``` -------------------------------- ### bootstrap() Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/_app.bootstrap.html Initializes the application by creating the data directory, opening database connections, and loading settings. If the application has already been bootstrapped, it calls ResetBootstrapState(). ```APIDOC ## bootstrap() ### Description Initializes the application (aka. create data dir, open db connections, load settings, etc.). It will call ResetBootstrapState() if the application was already bootstrapped. ### Method (Not applicable, this is a function call) ### Parameters None ### Returns `void` ### Defined in `types.d.ts:6144` ``` -------------------------------- ### execute() Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/_app.execute.html Initializes the application and executes the pb.RootCmd with graceful shutdown support. This method differs from pb.Start() by not registering the default system commands. ```APIDOC ## execute() ### Description Initializes the application (if not already) and executes the pb.RootCmd with graceful shutdown support. This method differs from pb.Start() by not registering the default system commands! ### Method execute() ### Returns void ``` -------------------------------- ### Get a normalized record data value Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.Record.html Use the `get(key)` method to retrieve a normalized single record model data value for the specified key. ```go record.get(key) ``` -------------------------------- ### _new() Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/pocketbase._new.html Creates a new PocketBase instance with the default configuration. For custom configurations, use NewWithConfig. Note that the application will not be initialized/bootstrapped until PocketBase.Start is executed. Manual bootstrapping is possible via PocketBase.Bootstrap. ```APIDOC ## _new() ### Description Creates a new PocketBase instance with the default configuration. Use [NewWithConfig] if you want to provide a custom configuration. Note that the application will not be initialized/bootstrapped yet, aka. DB connections, migrations, app settings, etc. will not be accessible. Everything will be initialized when [PocketBase.Start] is executed. If you want to initialize the application before calling [PocketBase.Start], then you'll have to manually call [PocketBase.Bootstrap]. ### Returns [pocketbase](../modules/pocketbase.html).[PocketBase](pocketbase.PocketBase.html) ### Defined in [types.d.ts:15093](https://github.com/pocketbase/site/blob/d10b615ad/jsvm/types.d.ts#L15093) ``` -------------------------------- ### Unmarshal JSON Field Example Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.BaseRecordProxy.html This example demonstrates how to retrieve a JSON field by its key and unmarshal its value into a provided result struct. Ensure the target struct has appropriate JSON tags for mapping. ```go result := struct { FirstName string `json:"first_name"` }{} err := m.UnmarshalJSONField("my_field_name", &result) ``` -------------------------------- ### newFilesystem Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.BaseApp.html Initializes a new general-purpose filesystem. ```APIDOC ## newFilesystem ### Description Initializes and returns a new general-purpose filesystem instance. ### Method Not specified (likely an SDK method) ### Endpoint Not specified ### Response #### Success Response (200) - **filesystem** (object) - The initialized filesystem object. #### Response Example ```json { "filesystem": { "type": "local", "path": "/data/files" } } ``` ``` -------------------------------- ### Command 'use' Option Example Source: https://github.com/pocketbase/site/blob/master/static/jsvm/classes/Command.html Illustrates the recommended syntax for the 'use' option, which defines the one-line usage message for a command. It explains the use of brackets for optional arguments, ellipsis for multiple values, and pipes for mutually exclusive options. ```plaintext add [-F file | -D dir]... [-f format] profile ``` -------------------------------- ### newWithConfig Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/pocketbase.newWithConfig.html Creates a new PocketBase instance with the provided configuration. The application is not yet initialized; this happens when PocketBase.Start() or PocketBase.Bootstrap() is called. ```APIDOC ## newWithConfig(config) ### Description Creates a new PocketBase instance with the provided config. Note that the application will not be initialized/bootstrapped yet, aka. DB connections, migrations, app settings, etc. will not be accessible. Everything will be initialized when [PocketBase.Start] is executed. If you want to initialize the application before calling [PocketBase.Start], then you'll have to manually call [PocketBase.Bootstrap]. ### Parameters #### Path Parameters - **config** (Config) - Description: Configuration object for PocketBase. ### Returns [pocketbase.PocketBase] * Defined in types.d.ts:15105 ``` -------------------------------- ### Get Client ID Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/subscriptions.Client.html Returns the unique identifier of the client. ```typescript id(): string[] ``` -------------------------------- ### Log Interface Methods Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.Log.html Provides access to methods for interacting with Log instances, such as checking if a record is new, retrieving the last saved primary key, marking records as new or not new, getting the primary key, performing post-scan operations, and getting the table name. ```APIDOC ## Methods ### isNew() * **Description**: Indicates what type of db query (insert or update) should be used with the model instance. * **Returns**: `boolean` ### lastSavedPK() * **Description**: Returns the last saved primary key of the model. Its value is updated to the latest PK value after MarkAsNotNew() or PostScan() calls. * **Returns**: `any` ### markAsNew() * **Description**: Clears the pk field and marks the current model as "new" (aka. forces m.IsNew() to be true). * **Returns**: `void` ### markAsNotNew() * **Description**: Sets the pk field to the Id value and marks the current model as NOT "new" (aka. forces m.IsNew() to be false). * **Returns**: `void` ### pk() * **Returns**: `any` ### postScan() * **Description**: Implements the [dbx.PostScanner] interface. It is usually executed right after the model is populated with the db row values. * **Returns**: `void` ### tableName() * **Description**: Returns the name of the table associated with the Log instance. * **Returns**: `string` ``` -------------------------------- ### Load and Render HTML Templates Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/template.html Demonstrates how to use the template registry to load HTML files and render them with data. The registry caches parsed files for subsequent calls. ```Go registry := template.NewRegistry() html1, err := registry.LoadFiles( // the files set wil be parsed only once and then cached "layout.html", "content.html", ).Render(map[string]any{"name": "John"}) hTML2, err := registry.LoadFiles( // reuse the already parsed and cached files set "layout.html", "content.html", ).Render(map[string]any{"name": "Jane"}) ``` -------------------------------- ### method Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/router.Route.html The HTTP method associated with this route (e.g., GET, POST). ```APIDOC ## method ### Description The HTTP method associated with this route. ### Type * string ``` -------------------------------- ### DirEntry Methods Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/fs.DirEntry.html Provides methods to get information about a directory entry. ```APIDOC ## Interface DirEntry A DirEntry is an entry read from a directory (using the [ReadDir] function or a [ReadDirFile]'s ReadDir method). ### Methods * [info](#info) * [isDir](#isDir) * [name](#name) * [type](#type) ### info() * info(): [fs](../modules/fs.html).[FileInfo](fs.FileInfo.html) * Info returns the FileInfo for the file or subdirectory described by the entry. The returned FileInfo may be from the time of the original directory read or from the time of the call to Info. If the file has been removed or renamed since the directory read, Info may return an error satisfying errors.Is(err, ErrNotExist). If the entry denotes a symbolic link, Info reports the information about the link itself, not the link's target. #### Returns [fs](../modules/fs.html).[FileInfo](fs.FileInfo.html) ### isDir() * isDir(): boolean * IsDir reports whether the entry describes a directory. #### Returns boolean ### name() * name(): string * Name returns the name of the file (or subdirectory) described by the entry. This name is only the final element of the path (the base name), not the entire path. For example, Name would return "hello.go" not "home/gopher/hello.go". #### Returns string ### type() * type(): [fs](../modules/fs.html).[FileMode](fs.FileMode.html) * Type returns the type bits for the entry. The type bits are a subset of the usual FileMode bits, those returned by the FileMode.Type method. #### Returns [fs](../modules/fs.html).[FileMode](fs.FileMode.html) ``` -------------------------------- ### Configuring HTTP Client Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/http.html Create an http.Client for control over headers and redirect policies. Clients are safe for concurrent use. ```Go client := &http.Client{ CheckRedirect: redirectPolicyFunc, } resp, err := client.Get("http://example.com") // ... ``` ```Go req, err := http.NewRequest("GET", "http://example.com", nil) // ... req.Header.Add("If-None-Match", `W/"wyzzy"`) resp, err := client.Do(req) // ... ``` -------------------------------- ### Get Proxied Record Model Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.ExternalAuth.html Returns the proxied Record model. ```typescript proxyRecord(): core.Record ``` -------------------------------- ### local Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/_filesystem.local.html Initializes a new local-only filesystem instance. It is recommended to use `$app.newFilesystem()` for constructing filesystems based on application settings. Ensure to call `close()` when done. ```APIDOC ## local(dirPath) ### Description Initializes a new local-only filesystem instance. Most users should prefer `$app.newFilesystem()` which will construct a local or S3 filesystem based on the configured application settings. Make sure to call `close()` after you are done working with it. ### Parameters #### Path Parameters * **dirPath** (string) - Required - The directory path for the local filesystem. ### Returns * [System](../interfaces/filesystem.System.html) - The initialized filesystem instance. ``` -------------------------------- ### get() Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.ExternalAuth.html Retrieves a field value from the ExternalAuth record. This method is inherited. ```APIDOC ## get(key) ### Description Retrieves a field value from the ExternalAuth record. ### Method get(key) ### Parameters #### Path Parameters - **key** (string) - Required - The key of the field to retrieve. ### Returns any - The value of the field. ``` -------------------------------- ### HashExp SQL Generation Example Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/dbx.HashExp.html Demonstrates how HashExp generates SQL WHERE clauses from map expressions. It handles direct values, nil for IS NULL, and slices for IN clauses. ```go HashExp{"level": 2, "dept": 10} will generate the SQL: "level"=2 AND "dept"=10. HashExp{"level": []interface{}{1, 2}, "dept": nil} will generate: "level" IN (1, 2) AND "dept" IS NULL. ``` -------------------------------- ### get Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/subscriptions.Client.html Retrieves a value from the client's context using a specified key. ```APIDOC ## get(key) ### Description Get retrieves the key value from the client's context. ### Parameters #### Path Parameters - **key** (string) - Description not specified in source. ### Returns `any` ### Defined in types.d.ts:22026 ``` -------------------------------- ### newBackupsFilesystem Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.BaseApp.html Initializes a new filesystem for backups. ```APIDOC ## newBackupsFilesystem ### Description Initializes and returns a new filesystem instance specifically configured for handling backups. ### Method Not specified (likely an SDK method) ### Endpoint Not specified ### Response #### Success Response (200) - **filesystem** (object) - The initialized backup filesystem object. #### Response Example ```json { "filesystem": { "type": "s3", "bucket": "my-backup-bucket" } } ``` ``` -------------------------------- ### Run Command Source: https://github.com/pocketbase/site/blob/master/static/jsvm/modules/exec.html Shows how to execute a command using exec.Command and run it to completion. This snippet will also not find programs in the current directory by default. ```go cmd := exec.Command("prog") if err := cmd.Run(); err != nil { log.Fatal(err) } ``` -------------------------------- ### Get Provider Field Value Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.ExternalAuth.html Retrieves the value of the 'provider' record field. ```typescript provider(): string ``` -------------------------------- ### Get Field by Name Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.FieldsList.html Retrieves a single field from the list using its name. ```Go l.GetByName(fieldName) ``` -------------------------------- ### Instantiate New AuthOrigin Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.newAuthOrigin.html Creates a new, blank AuthOrigin model. Use this to set record, collection, and fingerprint details before saving. ```go origin := core.NewOrigin(app) origin.SetRecordRef(user.Id) origin.SetCollectionRef(user.Collection().Id) origin.SetFingerprint("...") app.Save(origin) ``` -------------------------------- ### onSettingsListRequest Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/dbx.SelectQuery.html Hook triggered when a request is made to list system settings. Useful for customizing or restricting access to settings. ```APIDOC ## onSettingsListRequest ### Description This hook is invoked when a request is made to list the system settings. It can be used to customize the settings returned or to enforce access controls on sensitive configuration data. ### Method Event Hook ### Endpoint N/A (Internal SDK Hook) ### Parameters None explicitly documented for direct invocation. ### Response Allows modification of the system settings list or access permissions. ``` -------------------------------- ### NumberField.getId Source: https://github.com/pocketbase/site/blob/master/static/jsvm/classes/NumberField.html Gets the unique identifier for the field. This method implements the core.Field.GetId interface. ```APIDOC ## getId ### Description Gets the unique identifier for the field. This method implements the core.Field.GetId interface. ### Signature `getId(): string` ### Returns * `string` - The unique identifier of the field. ``` -------------------------------- ### deletePrefix Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/filesystem.System.html Deletes all files that start with the specified prefix. This can be used for subpaths or filename prefixes. ```APIDOC ## deletePrefix(prefix) ### Description Deletes everything starting with the specified prefix. The prefix could be subpath (ex. "/a/b/") or filename prefix (ex. "/a/b/file_"). ### Parameters #### Path Parameters * **prefix** (string) - Required - The prefix to match files for deletion. ### Returns Error[] ``` -------------------------------- ### Build Production Bundle Source: https://github.com/pocketbase/site/blob/master/README.md Generates a production-ready bundle of the website for deployment. ```sh npm run build ``` -------------------------------- ### stop Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/cron.Cron.html Stops the current cron ticker if it is running. You can resume the ticker by calling Start(). ```APIDOC ## stop ### Description Stops the current cron ticker if it is running. You can resume the ticker by calling Start(). ### Method `stop` ### Returns void Defined in types.d.ts:20331 ``` -------------------------------- ### s3 Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/_filesystem.s3.html Initializes a new S3-only filesystem instance. It's recommended to use `$app.newFilesystem()` for constructing local or S3 filesystems based on application settings. Ensure to call `close()` when done with the instance. ```APIDOC ## Function s3 ### Description Initializes a new S3-only filesystem instance. Most users should prefer `$app.newFilesystem()` which will construct a local or S3 filesystem based on the configured application settings. Make sure to call `close()` after you are done working with it. ### Parameters #### Path Parameters - **bucketName** (string) - Required - The name of the S3 bucket. - **region** (string) - Required - The AWS region for the S3 bucket. - **endpoint** (string) - Required - The S3 endpoint URL. - **accessKey** (string) - Required - The AWS access key ID. - **secretKey** (string) - Required - The AWS secret access key. - **s3ForcePathStyle** (boolean) - Required - Whether to force path-style S3 URLs. ### Returns - **[System](../interfaces/filesystem.System.html)** - An instance of the System interface representing the S3 filesystem. ``` -------------------------------- ### Get Allowed Fields Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.RecordFieldResolver.html Retrieves a copy of the fields that the RecordFieldResolver is configured to allow for searching. ```typescript resolver.allowedFields() ``` -------------------------------- ### Serve File from Filesystem in Go Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.CollectionsImportRequestEvent.html Serves a specified file from a given filesystem. This is similar to echo.FileFS for backward compatibility. ```go fileFS(fsys, filename) ``` -------------------------------- ### driverValue(record) Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.PasswordField.html Implements the DriverValuer interface to get the driver value for a given record. ```APIDOC ## driverValue(record) ### Description Implements the `DriverValuer` interface to provide a driver-specific value for a record. ### Method Not applicable (method call within SDK) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **record**: [core.Record](core.Record.html) - The record for which to get the driver value. ### Returns * **any** - The driver-specific value. ``` -------------------------------- ### Prepare and Execute OS Command Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/_os.cmd.html Use $os.cmd to prepare an external OS command with its arguments. The output can then be retrieved as a string using the .output() method. ```javascript const cmd = $os.cmd('ls', '-sl') const output = toString(cmd.output()); ``` -------------------------------- ### Get Provider ID Field Value Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.ExternalAuth.html Retrieves the value of the 'providerId' record field. ```typescript providerId(): string ``` -------------------------------- ### onBootstrap Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.App.html Hook triggered when initializing main application resources like db and app settings. ```APIDOC ## onBootstrap() ### Description OnBootstrap hook is triggered when initializing the main application resources (db, app settings, etc). ### Returns - [Hook](hook.Hook.html)<[BootstrapEvent](core.BootstrapEvent.html)> ``` -------------------------------- ### Get Field by ID Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.FieldsList.html Retrieves a single field from the list using its unique ID. ```Go l.GetById(fieldId) ``` -------------------------------- ### Get Field Names from FieldsList Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.FieldsList.html Returns a slice containing the names of all fields in the list. ```Go l.FieldNames() ``` -------------------------------- ### newFilesystem() Source: https://github.com/pocketbase/site/blob/master/static/jsvm/functions/_app.newFilesystem.html Creates a new local or S3 filesystem instance for managing regular app files (e.g., record uploads) based on the current app settings. Remember to call Close() on the returned result when done. ```APIDOC ## newFilesystem() ### Description Creates a new local or S3 filesystem instance for managing regular app files (e.g., record uploads) based on the current app settings. It is important to call `Close()` on the returned result when you are finished with it. ### Returns - [System](../interfaces/filesystem.System.html) - A new filesystem instance. ``` -------------------------------- ### Serve File from Filesystem Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.RecordAuthRefreshRequestEvent.html Serves a specified filename from a given filesystem. This is analogous to echo.FileFS for backward compatibility. ```go e.fileFS(fsys, filename) ``` -------------------------------- ### Get Table Name Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.AuthOrigin.html Retrieves the table name associated with the current Record model. ```typescript tableName(): string ``` -------------------------------- ### newS3 Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/filesystem.newS3.html Initializes a new S3 filesystem instance. It is important to call `Close()` after you are finished using it. ```APIDOC ## newS3 ### Description Initializes a new S3 filesystem instance. Remember to call `Close()` when done. ### Parameters * **bucketName** (string) - The name of the S3 bucket. * **region** (string) - The AWS region for the S3 bucket. * **endpoint** (string) - The S3 endpoint URL. * **accessKey** (string) - The AWS access key ID. * **secretKey** (string) - The AWS secret access key. * **s3ForcePathStyle** (boolean) - Whether to force path-style S3 URLs. ### Returns [System](filesystem.System.html) - An initialized S3 filesystem system instance. ``` -------------------------------- ### unwrap Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/apis.gzipResponseWriter.html Unwraps the gzipResponseWriter to get the underlying ResponseWriter. This method is part of the gzipResponseWriter interface. ```APIDOC ## unwrap ### Description Unwraps the gzipResponseWriter to get the underlying ResponseWriter. ### Method unwrap ### Parameters None ### Returns [http.ResponseWriter] ``` -------------------------------- ### get Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.BatchRequestEvent.html Retrieves a single value from the current event data store using the provided key. ```APIDOC ## get ### Description Retrieves a single value from the current event data store. ### Parameters * **key** (string) - The key of the value to retrieve. ### Returns any ``` -------------------------------- ### Instantiate and Configure New MFA Model Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.newMFA.html Use this snippet to create a new MFA model, set its record and collection references, specify the authentication method, and save it using the provided app instance. Ensure the app instance is available and the necessary references and method are correctly set before saving. ```go mfa := core.NewMFA(app) mfa.SetRecordRef(user.Id) mfa.SetCollectionRef(user.Collection().Id) mfa.SetMethod(core.MFAMethodPassword) app.Save(mfa) ``` -------------------------------- ### newBaseApp Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.newBaseApp.html Creates and returns a new BaseApp instance configured with the provided arguments. The app must be bootstrapped by calling `app.Bootstrap()` after initialization. ```APIDOC ## newBaseApp(config: BaseAppConfig): BaseApp ### Description Creates and returns a new BaseApp instance configured with the provided arguments. To initialize the app, you need to call `app.Bootstrap()`. ### Parameters #### config: BaseAppConfig - **config** (BaseAppConfig) - Description of the configuration object for BaseApp. ### Returns BaseApp - Returns a new instance of BaseApp. ``` -------------------------------- ### Get Client Context Value Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/subscriptions.Client.html Retrieves a value from the client's context using a specified key. ```typescript get(key: string): any[] ``` -------------------------------- ### Get the Number of Registered Hook Handlers Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/hook.Hook.html Returns the total count of currently registered hook handlers. ```typescript length(): number ``` -------------------------------- ### serveTLS Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/http.Server.html ServeTLS accepts incoming connections on the Listener l, creating a new service goroutine for each. The service goroutines perform TLS setup and then read requests, calling s.Handler to reply to them. ```APIDOC ## serveTLS ### Description ServeTLS accepts incoming connections on the Listener l, creating a new service goroutine for each. The service goroutines perform TLS setup and then read requests, calling s.Handler to reply to them. Files containing a certificate and matching private key for the server must be provided if neither the Server's TLSConfig.Certificates, TLSConfig.GetCertificate nor config.GetConfigForClient are populated. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate. ServeTLS always returns a non-nil error. After Server.Shutdown or Server.Close, the returned error is ErrServerClosed. ### Parameters #### Path Parameters * **l** (Listener) - The network listener to accept connections from. * **certFile** (string) - The path to the server's certificate file. * **keyFile** (string) - The path to the server's private key file. ### Returns void ``` -------------------------------- ### get(key) Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.Record.html Retrieves and returns a normalized single record model data value for the specified key. ```APIDOC ## get(key) ### Description Get returns a normalized single record model data value for "key". ### Parameters #### Path Parameters - **key** (string) - Description: The key of the data value to retrieve. ### Returns any * Defined in [types.d.ts:13206](https://github.com/pocketbase/site/blob/d10b615ad/jsvm/types.d.ts#L13206) ``` -------------------------------- ### newLocal Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/filesystem.newLocal.html Initializes a new local filesystem instance. It's important to call `Close()` when done with the instance. ```APIDOC ## newLocal(dirPath: string): System ### Description Initializes a new local filesystem instance. NB! Make sure to call `Close()` after you are done working with it. ### Parameters #### Path Parameters - **dirPath** (string) - Description: The directory path for the new local filesystem. ### Returns - **System** - A new local filesystem instance. ``` -------------------------------- ### Get Updated Timestamp Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.AuthOrigin.html Returns the 'updated' record field value, which represents the last modification timestamp. ```typescript updated(): DateTime ``` -------------------------------- ### Get Token Key Source: https://github.com/pocketbase/site/blob/master/static/jsvm/interfaces/core.AuthOrigin.html Retrieves the 'tokenKey' field value from a record, commonly used with authentication collections. ```typescript tokenKey(): string ```