PageSourceSearch

https://pocketbase.io/_app/immutable/nodes/55.DY2KvWc_.js

js pocketbase.io collected 2026-09-25 14:57:45 UTC 6,238 bytes, 61 lines download raw bytes

1import{s as le,d as o,n as ie,i as l,b as r,p as A,c as n,r as d,g as i,e as M,h as s,j as u}from"../chunks/scheduler.DQkMsCme.js";import{S as ue,i as ce,d as F,t as z,a as U,m as K,c as V,b as W}from"../chunks/index.DidmSOuj.js";import{C as D}from"../chunks/CodeTabs.C8NCXqAT.js";import{e as Q}from"../chunks/preferences.DKIoM6dL.js";function de(ae){let c,X=`One of the main features of PocketBase is that
2    <strong>it can be used as a framework</strong> which enables you to write your own custom app business
3    logic in
4    <a href="/docs/go-overview">Go</a> or <a href="/docs/js-overview">JavaScript</a> and still have a portable
5    backend at the end.`,G,g,Y=`<strong>Choose <a href="/docs/go-overview" class="label label-info">Extend with Go</a> if you are already familiar
6        with the language or have the time to learn it.</strong>
7    As the primary PocketBase language, the Go APIs are better documented and you&#39;ll be able to integrate with
8    any 3rd party Go library since you&#39;ll have more control over the application flow. The only drawback is that
9    the Go APIs are slightly more verbose and it may require some time to get used to, especially if this is your
10    first time working with Go.`,R,v,Z=`<strong>Choose <a href="/docs/js-overview" class="label label-warning">Extend with JavaScript</a>
11        if you don&#39;t intend to write too much custom code and want a quick way to explore the PocketBase capabilities.</strong>
12    The embedded JavaScript engine is a pluggable wrapper around the existing Go APIs, so most of the time the
13    slight performance penalty will be negligible because it&#39;ll invoke the Go functions under the hood.
14    <br/>
15    As a bonus, because the JS VM mirrors the Go APIs, you would be able migrate gradually without much code changes
16    from JS -&gt; Go at later stage in case you hit a bottleneck or want more control over the execution flow.`,T,b,ee="With both Go and JavaScript, you can:",k,a,m,y,te="Register custom routes:",j,w,I,p,_,oe="Bind to event hooks and intercept responses:",J,x,O,h,$,re="Register custom console commands:",B,C,N,S,ne="and many more...",E,f,se=`For further info, please check the related <a href="/docs/go-overview">Extend with Go</a> or
17    <a href="/docs/js-overview">Extend with JavaScript</a> guides.`,H;return w=new D({props:{group:Q,go:`
18                app.OnServe().BindFunc(func(se *core.ServeEvent) error {
19                    se.Router.GET("/hello", func(e *core.RequestEvent) error {
20                        return e.String(http.StatusOK, "Hello world!")
21                    })
22
23                    return se.Next()
24                })
25            `,js:`
26                routerAdd("GET", "/hello", (e) => {
27                    return e.string(200, "Hello world!")
28                })
29            `}}),x=new D({props:{group:Q,go:`
30                app.OnRecordCreateRequest("posts").BindFunc(func(e *core.RecordRequestEvent) error {
31                    // if not superuser, overwrite the newly submitted "posts" record status to pending
32                    if !e.HasSuperuserAuth() {
33                        e.Record.Set("status", "pending")
34                    }
35
36                    return e.Next()
37                })
38            `,js:`
39                onRecordCreateRequest((e) => {
40                    // if not superuser, overwrite the newly submitted "posts" record status to pending
41                    if (!e.hasSuperuserAuth()) {
42                        e.record.set("status", "pending")
43                    }
44
45                    e.next()
46                }, "posts")
47            `}}),C=new D({props:{group:Q,go:`
48                app.RootCmd.AddCommand(&cobra.Command{
49                    Use: "hello",
50                    Run: func(cmd *cobra.Command, args []string) {
51                        print("Hello world!")
52                    },
53                })
54            `,js:`
55                $app.rootCmd.addCommand(new Command({
56                    use: "hello",
57                    run: (cmd, args) => {
58                        console.log("Hello world!")
59                    },
60                }))
61            `}}),{c(){c=s("p"),c.innerHTML=X,G=u(),g=s("p"),g.innerHTML=Y,R=u(),v=s("p"),v.innerHTML=Z,T=u(),b=s("p"),b.textContent=ee,k=u(),a=s("ul"),m=s("li"),y=s("strong"),y.textContent=te,j=u(),W(w.$$.fragment),I=u(),p=s("li"),_=s("strong"),_.textContent=oe,J=u(),W(x.$$.fragment),O=u(),h=s("li"),$=s("strong"),$.textContent=re,B=u(),W(C.$$.fragment),N=u(),S=s("li"),S.textContent=ne,E=u(),f=s("p"),f.innerHTML=se,this.h()},l(e){c=n(e,"P",{"data-svelte-h":!0}),d(c)!=="svelte-1f96es3"&&(c.innerHTML=X),G=i(e),g=n(e,"P",{"data-svelte-h":!0}),d(g)!=="svelte-1ph7z8p"&&(g.innerHTML=Y),R=i(e),v=n(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-1gswc3z"&&(v.innerHTML=Z),T=i(e),b=n(e,"P",{"data-svelte-h":!0}),d(b)!=="svelte-1lmdcj4"&&(b.textContent=ee),k=i(e),a=n(e,"UL",{});var t=M(a);m=n(t,"LI",{class:!0});var L=M(m);y=n(L,"STRONG",{"data-svelte-h":!0}),d(y)!=="svelte-m9cpyq"&&(y.textContent=te),j=i(L),V(w.$$.fragment,L),L.forEac
61h(o),I=i(t),p=n(t,"LI",{class:!0});var P=M(p);_=n(P,"STRONG",{"data-svelte-h":!0}),d(_)!=="svelte-2yq98v"&&(_.textContent=oe),J=i(P),V(x.$$.fragment,P),P.forEach(o),O=i(t),h=n(t,"LI",{class:!0});var q=M(h);$=n(q,"STRONG",{"data-svelte-h":!0}),d($)!=="svelte-1ikfqb5"&&($.textContent=re),B=i(q),V(C.$$.fragment,q),q.forEach(o),N=i(t),S=n(t,"LI",{"data-svelte-h":!0}),d(S)!=="svelte-118x79l"&&(S.textContent=ne),t.forEach(o),E=i(e),f=n(e,"P",{class:!0,"data-svelte-h":!0}),d(f)!=="svelte-1oi5yt4"&&(f.innerHTML=se),this.h()},h(){A(m,"class","m-b-sm"),A(p,"class","m-b-sm"),A(h,"class","m-b-sm"),A(f,"class","m-t-base")},m(e,t){l(e,c,t),l(e,G,t),l(e,g,t),l(e,R,t),l(e,v,t),l(e,T,t),l(e,b,t),l(e,k,t),l(e,a,t),r(a,m),r(m,y),r(m,j),K(w,m,null),r(a,I),r(a,p),r(p,_),r(p,J),K(x,p,null),r(a,O),r(a,h),r(h,$),r(h,B),K(C,h,null),r(a,N),r(a,S),l(e,E,t),l(e,f,t),H=!0},p:ie,i(e){H||(U(w.$$.fragment,e),U(x.$$.fragment,e),U(C.$$.fragment,e),H=!0)},o(e){z(w.$$.fragment,e),z(x.$$.fragment,e),z(C.$$.fragment,e),H=!1},d(e){e&&(o(c),o(G),o(g),o(R),o(v),o(T),o(b),o(k),o(a),o(E),o(f)),F(w),F(x),F(C)}}}class ge extends ue{constructor(c){super(),ce(this,c,null,de,le,{})}}export{ge as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.