adds svelte API
This commit is contained in:
@@ -5,7 +5,7 @@ WORKDIR /
|
||||
|
||||
COPY go.mod ./
|
||||
COPY go.sum ./
|
||||
COPY pb_migrations ./pb_migrations
|
||||
COPY migrations ./migrations
|
||||
|
||||
RUN go mod download
|
||||
|
||||
@@ -14,8 +14,8 @@ COPY *.go ./
|
||||
RUN go build -o /pocketbase
|
||||
RUN /pocketbase migrate
|
||||
|
||||
ENV PUBLIC_MEILISEARCH_URL=http://localhost:7700
|
||||
ENV MEILISEARCH_MASTER_KEY=
|
||||
ENV MEILI_URL=http://localhost:7700
|
||||
ENV MEILI_MASTER_KEY=
|
||||
|
||||
EXPOSE 8090
|
||||
|
||||
|
||||
12
db/main.go
12
db/main.go
@@ -9,6 +9,9 @@ import (
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/plugins/migratecmd"
|
||||
|
||||
_ "pocketbase/migrations"
|
||||
)
|
||||
|
||||
func indexRecord(r *models.Record, client *meilisearch.Client) error {
|
||||
@@ -43,9 +46,14 @@ func indexRecord(r *models.Record, client *meilisearch.Client) error {
|
||||
func main() {
|
||||
app := pocketbase.New()
|
||||
|
||||
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
|
||||
Dir: "migrations",
|
||||
Automigrate: true,
|
||||
})
|
||||
|
||||
client := meilisearch.NewClient(meilisearch.ClientConfig{
|
||||
Host: os.Getenv("PUBLIC_MEILISEARCH_URL"),
|
||||
APIKey: os.Getenv("MEILISEARCH_MASTER_KEY"),
|
||||
Host: os.Getenv("MEILI_URL"),
|
||||
APIKey: os.Getenv("MEILI_MASTER_KEY"),
|
||||
})
|
||||
|
||||
app.OnRecordAfterCreateRequest("users").Add(func(e *core.RecordCreateEvent) error {
|
||||
|
||||
665
db/migrations/1709593298_collections_snapshot.go
Normal file
665
db/migrations/1709593298_collections_snapshot.go
Normal file
@@ -0,0 +1,665 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `[
|
||||
{
|
||||
"id": "_pb_users_auth_",
|
||||
"created": "2024-01-26 15:05:23.262Z",
|
||||
"updated": "2024-02-29 16:52:40.743Z",
|
||||
"name": "users",
|
||||
"type": "auth",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "dlzhxcn2",
|
||||
"name": "token",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "users_avatar",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null,
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "wjofulpg",
|
||||
"name": "unit",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"metric",
|
||||
"imperial"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "t1wlsqyp",
|
||||
"name": "language",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"en",
|
||||
"de"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "wosrk4ue",
|
||||
"name": "location",
|
||||
"type": "json",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSize": 2000000
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "id = @request.auth.id",
|
||||
"viewRule": "id = @request.auth.id",
|
||||
"createRule": "",
|
||||
"updateRule": "id = @request.auth.id",
|
||||
"deleteRule": "id = @request.auth.id",
|
||||
"options": {
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": null,
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": null,
|
||||
"onlyVerified": false,
|
||||
"requireEmail": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "e864strfxo14pm4",
|
||||
"created": "2024-01-26 18:46:35.843Z",
|
||||
"updated": "2024-02-23 12:47:30.327Z",
|
||||
"name": "trails",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "wquvuytd",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "6kkucam1",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "8x74ba26",
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ehrmydva",
|
||||
"name": "public",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "epgmtyxy",
|
||||
"name": "distance",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "5wxdt3aj",
|
||||
"name": "elevation_gain",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ukr9rqz4",
|
||||
"name": "duration",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "eqeqja1s",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "y6dbfyw6",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "mcqce8l9",
|
||||
"name": "thumbnail",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "aqbpyawe",
|
||||
"name": "photos",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/png",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "k8xdrsyv",
|
||||
"name": "gpx",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "b49obm5u",
|
||||
"name": "category",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "kjxvi8asj2igqwf",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "1utgul91",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "e1lwowvd",
|
||||
"name": "summit_logs",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "dd2l9a4vxpy2ni8",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ppq2sist",
|
||||
"name": "waypoints",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "goeo2ubp103rzp9",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "author = @request.auth.id || public = true",
|
||||
"viewRule": "author = @request.auth.id || public = true",
|
||||
"createRule": "@request.auth.id != \"\" && (@request.data.author = @request.auth.id)",
|
||||
"updateRule": "author = @request.auth.id ",
|
||||
"deleteRule": "author = @request.auth.id ",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "kjxvi8asj2igqwf",
|
||||
"created": "2024-01-26 18:47:30.797Z",
|
||||
"updated": "2024-01-27 09:38:36.240Z",
|
||||
"name": "categories",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "38tbd8u4",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "64dsnxtb",
|
||||
"name": "img",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "goeo2ubp103rzp9",
|
||||
"created": "2024-01-26 18:50:13.695Z",
|
||||
"updated": "2024-02-04 11:49:30.732Z",
|
||||
"name": "waypoints",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "2yegzjtk",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "3xtcjtxv",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ygotgxzy",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "q0ygnxd2",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "rnjgm2tk",
|
||||
"name": "icon",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"viewRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"createRule": "@request.auth.id != \"\"",
|
||||
"updateRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"deleteRule": "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "dd2l9a4vxpy2ni8",
|
||||
"created": "2024-01-27 12:23:48.069Z",
|
||||
"updated": "2024-02-02 21:24:15.600Z",
|
||||
"name": "summit_logs",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "gxq1yeld",
|
||||
"name": "date",
|
||||
"type": "date",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": "",
|
||||
"max": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "0ykzwuia",
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"viewRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)",
|
||||
"createRule": "@request.auth.id != \"\"",
|
||||
"updateRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"deleteRule": "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "r6gu2ajyidy1x69",
|
||||
"created": "2024-02-27 11:46:07.367Z",
|
||||
"updated": "2024-02-27 13:22:52.195Z",
|
||||
"name": "lists",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "0goi1ipa",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "3v3pwnqn",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "decatj0h",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/jpeg",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "jqtcrcnq",
|
||||
"name": "trails",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "kwm6zdet",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "author = @request.auth.id ",
|
||||
"viewRule": "author = @request.auth.id ",
|
||||
"createRule": "author = @request.auth.id ",
|
||||
"updateRule": "author = @request.auth.id ",
|
||||
"deleteRule": "author = @request.auth.id ",
|
||||
"options": {}
|
||||
}
|
||||
]`
|
||||
|
||||
collections := []*models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collections); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).ImportCollections(collections, true, nil)
|
||||
}, func(db dbx.Builder) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
74
db/migrations/1709982456_updated_trails.go
Normal file
74
db/migrations/1709982456_updated_trails.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("mcqce8l9")
|
||||
|
||||
// add
|
||||
new_thumbnail := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "k2giqyjq",
|
||||
"name": "thumbnail",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}`), new_thumbnail)
|
||||
collection.Schema.AddField(new_thumbnail)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("e864strfxo14pm4")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
del_thumbnail := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "mcqce8l9",
|
||||
"name": "thumbnail",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_thumbnail)
|
||||
collection.Schema.AddField(del_thumbnail)
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("k2giqyjq")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const collection = new Collection({
|
||||
"id": "e864strfxo14pm4",
|
||||
"created": "2024-01-26 18:46:35.843Z",
|
||||
"updated": "2024-01-26 18:46:35.843Z",
|
||||
"name": "trails",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "wquvuytd",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "jjiidvbm",
|
||||
"name": "thumbnail",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "6kkucam1",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
}, (db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "k8xdrsyv",
|
||||
"name": "gpx",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("k8xdrsyv")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,57 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const collection = new Collection({
|
||||
"id": "kjxvi8asj2igqwf",
|
||||
"created": "2024-01-26 18:47:30.797Z",
|
||||
"updated": "2024-01-26 18:47:30.797Z",
|
||||
"name": "categories",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "38tbd8u4",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "64dsnxtb",
|
||||
"name": "img",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
}, (db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("kjxvi8asj2igqwf");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "b49obm5u",
|
||||
"name": "category",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "kjxvi8asj2igqwf",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("b49obm5u")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,69 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const collection = new Collection({
|
||||
"id": "goeo2ubp103rzp9",
|
||||
"created": "2024-01-26 18:50:13.695Z",
|
||||
"updated": "2024-01-26 18:50:13.695Z",
|
||||
"name": "waypoints",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "2yegzjtk",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ygotgxzy",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "q0ygnxd2",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
}, (db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "aqbpyawe",
|
||||
"name": "photos",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/jpeg",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/png",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 99,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("aqbpyawe")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,92 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "jjiidvbm",
|
||||
"name": "thumbnail",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/jpeg",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "k8xdrsyv",
|
||||
"name": "gpx",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"application/gpx+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "jjiidvbm",
|
||||
"name": "thumbnail",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "k8xdrsyv",
|
||||
"name": "gpx",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "1utgul91",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("1utgul91")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,50 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "epgmtyxy",
|
||||
"name": "distance",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "5wxdt3aj",
|
||||
"name": "elevation_gain",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("epgmtyxy")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("5wxdt3aj")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,44 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "wquvuytd",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "wquvuytd",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "8x74ba26",
|
||||
"name": "location",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("8x74ba26")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ukr9rqz4",
|
||||
"name": "time",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("ukr9rqz4")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,44 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ukr9rqz4",
|
||||
"name": "duration",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ukr9rqz4",
|
||||
"name": "time",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.listRule = null
|
||||
collection.viewRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("kjxvi8asj2igqwf")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("kjxvi8asj2igqwf")
|
||||
|
||||
collection.listRule = null
|
||||
collection.viewRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,54 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const collection = new Collection({
|
||||
"id": "dd2l9a4vxpy2ni8",
|
||||
"created": "2024-01-27 12:23:48.069Z",
|
||||
"updated": "2024-01-27 12:23:48.069Z",
|
||||
"name": "summit_book",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "gxq1yeld",
|
||||
"name": "date",
|
||||
"type": "date",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": "",
|
||||
"max": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "0ykzwuia",
|
||||
"name": "text",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
});
|
||||
|
||||
return Dao(db).saveCollection(collection);
|
||||
}, (db) => {
|
||||
const dao = new Dao(db);
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8");
|
||||
|
||||
return dao.deleteCollection(collection);
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.name = "summit_log"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.name = "summit_book"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,54 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "e1lwowvd",
|
||||
"name": "summit_logs",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "dd2l9a4vxpy2ni8",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ppq2sist",
|
||||
"name": "waypoints",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "goeo2ubp103rzp9",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("e1lwowvd")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("ppq2sist")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = null
|
||||
collection.viewRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = null
|
||||
collection.viewRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "xwqncqng",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("xwqncqng")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "0fz9yp7c",
|
||||
"name": "trail",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("0fz9yp7c")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,54 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("xwqncqng")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "b4zqrqpa",
|
||||
"name": "trail",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "xwqncqng",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("b4zqrqpa")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("0fz9yp7c")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "0fz9yp7c",
|
||||
"name": "trail",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("b4zqrqpa")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "b4zqrqpa",
|
||||
"name": "trail",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "e864strfxo14pm4",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,76 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ygotgxzy",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "q0ygnxd2",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ygotgxzy",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "q0ygnxd2",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "rnjgm2tk",
|
||||
"name": "icon",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("rnjgm2tk")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "3xtcjtxv",
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("3xtcjtxv")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,58 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("jjiidvbm")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "mcqce8l9",
|
||||
"name": "thumbnail",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "jjiidvbm",
|
||||
"name": "thumbnail",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"mimeTypes": [
|
||||
"image/png",
|
||||
"image/vnd.mozilla.apng",
|
||||
"image/jpeg",
|
||||
"image/webp",
|
||||
"image/svg+xml"
|
||||
],
|
||||
"thumbs": [],
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"protected": false
|
||||
}
|
||||
}))
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("mcqce8l9")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,76 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ygotgxzy",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "q0ygnxd2",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ygotgxzy",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "q0ygnxd2",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.createRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.createRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,84 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "e1lwowvd",
|
||||
"name": "summit_logs",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "dd2l9a4vxpy2ni8",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ppq2sist",
|
||||
"name": "waypoints",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "goeo2ubp103rzp9",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "e1lwowvd",
|
||||
"name": "summit_logs",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "dd2l9a4vxpy2ni8",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ppq2sist",
|
||||
"name": "waypoints",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "goeo2ubp103rzp9",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.createRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.createRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,84 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "e1lwowvd",
|
||||
"name": "summit_logs",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "dd2l9a4vxpy2ni8",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ppq2sist",
|
||||
"name": "waypoints",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "goeo2ubp103rzp9",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "e1lwowvd",
|
||||
"name": "summit_logs",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "dd2l9a4vxpy2ni8",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ppq2sist",
|
||||
"name": "waypoints",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "goeo2ubp103rzp9",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.createRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.createRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.name = "summit_logs"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.name = "summit_log"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.updateRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.updateRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.deleteRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.deleteRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.updateRule = ""
|
||||
collection.deleteRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.updateRule = null
|
||||
collection.deleteRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.updateRule = ""
|
||||
collection.deleteRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.updateRule = null
|
||||
collection.deleteRule = null
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("users_name")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "users_name",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,27 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "ehrmydva",
|
||||
"name": "public",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("ehrmydva")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,48 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "1utgul91",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": true,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": true,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// update
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "1utgul91",
|
||||
"name": "author",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "_pb_users_auth_",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": null
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.listRule = "author = @request.auth.id || public = true"
|
||||
collection.viewRule = "author = @request.auth.id || public = true"
|
||||
collection.createRule = "@request.auth.id != \"\" && (@request.data.author = @request.auth.id)"
|
||||
collection.updateRule = "author = @request.auth.id "
|
||||
collection.deleteRule = "author = @request.auth.id "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
collection.createRule = ""
|
||||
collection.updateRule = ""
|
||||
collection.deleteRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.createRule = "@request.auth.id != \"\""
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
collection.createRule = ""
|
||||
collection.updateRule = ""
|
||||
collection.deleteRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.createRule = "@request.auth.id != \"\""
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
collection.createRule = ""
|
||||
collection.updateRule = ""
|
||||
collection.deleteRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\""
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.viewRule = "author = @request.auth.id || public = true"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.viewRule = "author = @request.auth.id || public = true"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
collection.viewRule = ""
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||
collection.viewRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||
|
||||
collection.listRule = ""
|
||||
collection.viewRule = ""
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,50 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "eqeqja1s",
|
||||
"name": "lat",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
// add
|
||||
collection.schema.addField(new SchemaField({
|
||||
"system": false,
|
||||
"id": "y6dbfyw6",
|
||||
"name": "lon",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"noDecimal": false
|
||||
}
|
||||
}))
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("eqeqja1s")
|
||||
|
||||
// remove
|
||||
collection.schema.removeField("y6dbfyw6")
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
}, (db) => {
|
||||
const dao = new Dao(db)
|
||||
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||
|
||||
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||
|
||||
return dao.saveCollection(collection)
|
||||
})
|
||||
@@ -0,0 +1,57 @@
|
||||
version: '3'
|
||||
|
||||
x-common-env: &cenv
|
||||
MEILI_URL: http://search:7700
|
||||
MEILI_MASTER_KEY: CHANGE_ME!
|
||||
|
||||
services:
|
||||
search:
|
||||
image: getmeili/meilisearch:v1.6.2
|
||||
environment:
|
||||
<<: *cenv
|
||||
MEILI_NO_ANALYTICS: true
|
||||
MEILI_HTTP_PAYLOAD_SIZE_LIMIT: 150 Mb
|
||||
ports:
|
||||
- 7700:7700
|
||||
networks:
|
||||
- wanderer
|
||||
volumes:
|
||||
- ./data/data.ms:/meili_data/data.ms
|
||||
restart: unless-stopped
|
||||
|
||||
bootstrap:
|
||||
build: ./search
|
||||
environment:
|
||||
<<: *cenv
|
||||
depends_on:
|
||||
search:
|
||||
condition: service_started
|
||||
networks:
|
||||
- wanderer
|
||||
db:
|
||||
build: ./db
|
||||
environment:
|
||||
<<: *cenv
|
||||
ports:
|
||||
- "8090:8090"
|
||||
networks:
|
||||
- wanderer
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data/pb_data:/pb_data
|
||||
|
||||
web:
|
||||
build: ./web
|
||||
environment:
|
||||
PUBLIC_MEILISEARCH_URL: http://localhost:7700
|
||||
PUBLIC_MEILISEARCH_API_TOKEN:
|
||||
PUBLIC_POCKETBASE_URL: http://127.0.0.1:8090
|
||||
ports:
|
||||
- "8080:3000"
|
||||
networks:
|
||||
- wanderer
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
wanderer:
|
||||
driver: bridge
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
FROM python:3.10-slim
|
||||
WORKDIR /app
|
||||
|
||||
COPY init.py /app
|
||||
COPY bootstrap.py /app
|
||||
COPY cities500.tar.gz /app
|
||||
|
||||
RUN tar -xvf cities500.tar.gz
|
||||
RUN pip install meilisearch==0.30.0
|
||||
|
||||
ENV PUBLIC_MEILISEARCH_URL=http://localhost:7700
|
||||
ENV MEILISEARCH_MASTER_KEY=
|
||||
ENV MEILI_URL=http://localhost:7700
|
||||
ENV MEILI_MASTER_KEY=
|
||||
|
||||
CMD ["python", "./init.py"]
|
||||
CMD ["python", "-u", "./bootstrap.py"]
|
||||
65
search/bootstrap.py
Normal file
65
search/bootstrap.py
Normal file
@@ -0,0 +1,65 @@
|
||||
from meilisearch import Client
|
||||
from meilisearch.errors import MeilisearchApiError
|
||||
import json
|
||||
import os
|
||||
|
||||
MEILI_URL=os.getenv('MEILI_URL')
|
||||
MEILI_MASTER_KEY=os.getenv('MEILI_MASTER_KEY')
|
||||
|
||||
client = Client(MEILI_URL, MEILI_MASTER_KEY)
|
||||
|
||||
def index_exists(index_name: str) -> bool:
|
||||
try:
|
||||
client.get_index(index_name)
|
||||
return True
|
||||
except MeilisearchApiError:
|
||||
return False
|
||||
|
||||
def init_indices():
|
||||
if not index_exists('cities500'):
|
||||
print("Creating cities index...")
|
||||
client.create_index('cities500', {'primaryKey': 'id'})
|
||||
|
||||
client.index('cities500').update_settings({
|
||||
'sortableAttributes': ['_geo',],
|
||||
'filterableAttributes': ['_geo']
|
||||
})
|
||||
|
||||
print("Starting data import...")
|
||||
json_file = open('cities500.json', encoding='utf-8')
|
||||
cities = json.load(json_file)
|
||||
|
||||
client.index('cities500').add_documents(cities)
|
||||
print("Data import completed!")
|
||||
|
||||
if not index_exists('trails'):
|
||||
print("Creating trails index...")
|
||||
client.create_index('trails', {'primaryKey': 'id'})
|
||||
|
||||
client.index('trails').update_settings({
|
||||
'sortableAttributes': ['name', 'distance', 'elevation_gain', 'created',],
|
||||
'filterableAttributes': ['category', 'distance', 'elevation_gain', 'completed', '_geo', 'public', 'author']
|
||||
})
|
||||
|
||||
|
||||
def generate_public_token():
|
||||
search_key = client.get_keys().results[0]
|
||||
|
||||
search_rules = {
|
||||
'trails': {
|
||||
'filter': 'public=true'
|
||||
},
|
||||
'cities500': {}
|
||||
}
|
||||
token = client.generate_tenant_token(api_key_uid=search_key.uid, search_rules=search_rules, api_key=search_key.key)
|
||||
|
||||
return token
|
||||
|
||||
print("Initializing indices...")
|
||||
init_indices()
|
||||
print("Indices initialized!")
|
||||
token = generate_public_token()
|
||||
print("Generating public token...")
|
||||
print(f"PUBLIC_MEILISEARCH_API_TOKEN:{token}")
|
||||
|
||||
print("Bootstrapping complete!")
|
||||
@@ -1,44 +0,0 @@
|
||||
from meilisearch import Client
|
||||
import json
|
||||
import os
|
||||
|
||||
PUBLIC_MEILISEARCH_URL=os.getenv('MEILISEARCH_URL')
|
||||
MEILISEARCH_MASTER_KEY=os.getenv('MEILISEARCH_MASTER_KEY')
|
||||
|
||||
client = Client(MEILISEARCH_URL, MEILISEARCH_MASTER_KEY)
|
||||
|
||||
def init():
|
||||
client.create_index('cities500', {'primaryKey': 'id'})
|
||||
|
||||
client.index('cities500').update_settings({
|
||||
'sortableAttributes': ['_geo',],
|
||||
'filterableAttributes': ['_geo']
|
||||
})
|
||||
|
||||
client.create_index('trails', {'primaryKey': 'id'})
|
||||
|
||||
client.index('trails').update_settings({
|
||||
'sortableAttributes': ['name', 'distance', 'elevation_gain', 'created',],
|
||||
'filterableAttributes': ['category', 'distance', 'elevation_gain', 'completed', '_geo', 'public', 'author']
|
||||
})
|
||||
|
||||
|
||||
json_file = open('cities500.json', encoding='utf-8')
|
||||
cities = json.load(json_file)
|
||||
|
||||
client.index('cities500').add_documents(cities)
|
||||
|
||||
def generate_public_token():
|
||||
search_key = client.get_keys().results[0]
|
||||
|
||||
search_rules = {
|
||||
'trails': {
|
||||
'filter': 'public=true'
|
||||
},
|
||||
'cities500': {}
|
||||
}
|
||||
token = client.generate_tenant_token(api_key_uid=search_key.uid, search_rules=search_rules, api_key=search_key.key)
|
||||
|
||||
print(token)
|
||||
|
||||
generate_public_token()
|
||||
@@ -13,9 +13,12 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
// validate the user existence and if the path is acceesible
|
||||
if (!pb.authStore.model && isRouteProtected(url.pathname)) {
|
||||
throw redirect(302, '/login');
|
||||
} else if (pb.authStore.model && url.pathname === "/login") {
|
||||
throw redirect(302, '/');
|
||||
}
|
||||
|
||||
regenerateInstance();
|
||||
|
||||
try {
|
||||
// get an up-to-date auth store state by verifying and refreshing the loaded auth model (if any)
|
||||
if (pb.authStore.isValid) {
|
||||
@@ -30,10 +33,10 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
event.locals.user = pb.authStore.model
|
||||
|
||||
const lang = pb.authStore.model?.language ?? event.request.headers.get('accept-language')?.split(',')[0]
|
||||
|
||||
if (lang) {
|
||||
locale.set(lang)
|
||||
}
|
||||
|
||||
if (lang) {
|
||||
locale.set(lang)
|
||||
}
|
||||
|
||||
const response = await resolve(event)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { List } from "$lib/models/list";
|
||||
import { getFileURL } from "$lib/util/file_util";
|
||||
import Dropdown, { type DropdownItem } from "../base/dropdown.svelte";
|
||||
import { _ } from "svelte-i18n";
|
||||
export let list: List;
|
||||
@@ -17,8 +18,8 @@
|
||||
>
|
||||
{#if list.avatar}
|
||||
<img
|
||||
class="w-16 md:w-24 aspect-square rounded-full"
|
||||
src={list.avatar}
|
||||
class="w-16 md:w-24 aspect-square rounded-full object-cover"
|
||||
src={getFileURL(list, list.avatar)}
|
||||
alt="avatar"
|
||||
/>
|
||||
{:else}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import Modal from "../base/modal.svelte";
|
||||
import TextField from "../base/text_field.svelte";
|
||||
import Textarea from "../base/textarea.svelte";
|
||||
import { getFileURL } from "$lib/util/file_util";
|
||||
export let openModal: (() => void) | undefined = undefined;
|
||||
export let closeModal: (() => void) | undefined = undefined;
|
||||
|
||||
@@ -21,12 +22,7 @@
|
||||
initialValues: $list,
|
||||
validationSchema: listSchema,
|
||||
onSubmit: async (submittedList) => {
|
||||
const htmlForm = document.getElementById(
|
||||
"list-form",
|
||||
) as HTMLFormElement;
|
||||
const formData = new FormData(htmlForm);
|
||||
|
||||
dispatch("save", { list: submittedList, formData: formData });
|
||||
dispatch("save", { list: submittedList, avatar: (document.getElementById("avatar") as HTMLInputElement).files![0] });
|
||||
(document.getElementById("avatar") as HTMLInputElement).value = "";
|
||||
closeModal!();
|
||||
},
|
||||
@@ -48,7 +44,7 @@
|
||||
}
|
||||
$: if (browser) {
|
||||
form.set(util.cloneDeep($list));
|
||||
previewURL = $list.avatar ?? "";
|
||||
previewURL = getFileURL($list, $list.avatar) ?? "";
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -78,7 +74,7 @@
|
||||
<div class="flex items-center gap-4">
|
||||
{#if previewURL.length > 0}
|
||||
<img
|
||||
class="w-32 aspect-square rounded-full"
|
||||
class="w-32 aspect-square rounded-full object-cover"
|
||||
alt="avatar"
|
||||
src={previewURL}
|
||||
/>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { trail } from "$lib/stores/trail_store";
|
||||
import { _ } from "svelte-i18n";
|
||||
import Modal from "../base/modal.svelte";
|
||||
import { getFileURL } from "$lib/util/file_util";
|
||||
|
||||
export let openModal: (() => void) | undefined = undefined;
|
||||
export let closeModal: (() => void) | undefined = undefined;
|
||||
@@ -42,7 +43,7 @@
|
||||
{#if list.avatar}
|
||||
<img
|
||||
class="w-12 aspect-square rounded-full"
|
||||
src={list.avatar}
|
||||
src={getFileURL(list, list.avatar)}
|
||||
alt="avatar"
|
||||
/>
|
||||
{:else}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
></i>
|
||||
{/if}
|
||||
<div
|
||||
class="flex opacity-0 group-hover:opacity-100 absolute top-0 w-full h-full bg-white bg-opacity-75 items-center justify-center gap-6 transition-all"
|
||||
class="flex opacity-0 group-hover:opacity-100 absolute top-0 w-full h-full bg-white/75 rounded-xl items-center justify-center gap-6 transition-all"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<script lang="ts">
|
||||
import type { Trail } from "$lib/models/trail";
|
||||
import { getFileURL } from "$lib/util/file_util";
|
||||
import { formatDistance, formatElevation, formatTimeHHMM } from "$lib/util/format_util";
|
||||
import {
|
||||
formatDistance,
|
||||
formatElevation,
|
||||
formatTimeHHMM,
|
||||
} from "$lib/util/format_util";
|
||||
|
||||
export let trail: Trail;
|
||||
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -14,7 +17,7 @@
|
||||
role="listitem"
|
||||
>
|
||||
<div class="w-full min-h-40 max-h-48 overflow-hidden rounded-t-2xl">
|
||||
<img src={getFileURL(trail, trail.thumbnail)} alt="" />
|
||||
<img src={getFileURL(trail, trail.photos[trail.thumbnail])} alt="" />
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<div>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="shrink-0">
|
||||
<img
|
||||
class="h-28 w-28 object-cover rounded-xl"
|
||||
src={getFileURL(trail, trail.thumbnail)}
|
||||
src={getFileURL(trail, trail.photos[trail.thumbnail])}
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -13,10 +13,13 @@ class Trail {
|
||||
duration?: number;
|
||||
lat?: number;
|
||||
lon?: number;
|
||||
thumbnail?: string;
|
||||
thumbnail: number;
|
||||
photos: string[];
|
||||
gpx?: string;
|
||||
created?: string;
|
||||
category?: string;
|
||||
waypoints: string[];
|
||||
summit_logs: string[];
|
||||
expand: {
|
||||
category?: Category;
|
||||
waypoints: Waypoint[]
|
||||
@@ -27,8 +30,6 @@ class Trail {
|
||||
description?: string;
|
||||
author?: string;
|
||||
|
||||
_photoFiles: File[]
|
||||
|
||||
constructor(name: string,
|
||||
params?: {
|
||||
id?: string,
|
||||
@@ -39,7 +40,7 @@ class Trail {
|
||||
duration?: number,
|
||||
lat?:number,
|
||||
lon?: number,
|
||||
thumbnail?: string,
|
||||
thumbnail?: number,
|
||||
photos?: string[],
|
||||
gpx?: string,
|
||||
category?: Category,
|
||||
@@ -60,8 +61,10 @@ class Trail {
|
||||
this.duration = params?.duration;
|
||||
this.lat = params?.lat;
|
||||
this.lon = params?.lon;
|
||||
this.thumbnail = params?.thumbnail;
|
||||
this.thumbnail = params?.thumbnail ?? 0;
|
||||
this.photos = params?.photos ?? [];
|
||||
this.waypoints = [];
|
||||
this.summit_logs = [];
|
||||
this.gpx = params?.gpx;
|
||||
this.expand = {
|
||||
category: params?.category,
|
||||
@@ -71,7 +74,6 @@ class Trail {
|
||||
this.tags = params?.tags ?? []
|
||||
this.description = params?.description ?? "";
|
||||
this.created = params?.created;
|
||||
this._photoFiles = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,66 +2,130 @@ import { List, type ListFilter } from "$lib/models/list";
|
||||
import type { Trail } from "$lib/models/trail";
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { getFileURL } from "$lib/util/file_util";
|
||||
import { ClientResponseError } from "pocketbase";
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
|
||||
export const lists: Writable<List[]> = writable([])
|
||||
export const list: Writable<List> = writable(new List("", []))
|
||||
|
||||
|
||||
export async function lists_index(filter?: ListFilter) {
|
||||
const dbResponse: List[] = (await pb.collection('lists').getFullList<List>({
|
||||
expand: "trails",
|
||||
sort: `${filter?.sortOrder ?? "+"}${filter?.sort ?? "name"}`
|
||||
}))
|
||||
export async function lists_index(filter?: ListFilter, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
||||
const r = await f('/api/v1/list?' + new URLSearchParams({
|
||||
sort: `${filter?.sortOrder ?? "-"}${filter?.sort ?? "name"}`,
|
||||
}), {
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
for (const list of dbResponse) {
|
||||
list.avatar = getFileURL(list, list.avatar);
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
lists.set(dbResponse);
|
||||
const fetchedLists: List[] = await r.json();
|
||||
|
||||
if (dbResponse.length > 0) {
|
||||
list.set(dbResponse[0])
|
||||
lists.set(fetchedLists);
|
||||
|
||||
if (fetchedLists.length > 0) {
|
||||
list.set(fetchedLists[0])
|
||||
}
|
||||
|
||||
return dbResponse;
|
||||
return fetchedLists;
|
||||
|
||||
}
|
||||
|
||||
export async function lists_create(formData: { [key: string]: any; } | FormData) {
|
||||
export async function lists_create(list: List, avatar?: File) {
|
||||
if (!pb.authStore.model) {
|
||||
throw new Error("Unauthenticated");
|
||||
}
|
||||
|
||||
formData.append("author", pb.authStore.model!.id);
|
||||
list.author = pb.authStore.model!.id;
|
||||
|
||||
let model = await pb
|
||||
.collection("lists")
|
||||
.create<List>(formData);
|
||||
}
|
||||
let r = await fetch('/api/v1/list', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(list),
|
||||
})
|
||||
|
||||
export async function lists_update(list: List, formData: { [key: string]: any; } | FormData) {
|
||||
if ((formData.get("avatar") as File).size == 0) {
|
||||
formData.delete("avatar");
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
const model: List = await r.json();
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
if (avatar) {
|
||||
formData.append("avatar", avatar);
|
||||
}
|
||||
|
||||
r = await fetch(`/api/v1/list/${model.id!}/file`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
let model = await pb
|
||||
.collection("lists")
|
||||
.update<List>(list.id!, formData);
|
||||
}
|
||||
|
||||
export async function lists_delete(list: List) {
|
||||
let success = await pb
|
||||
.collection("lists")
|
||||
.delete(list.id!);
|
||||
export async function lists_update(list: List, avatar?: File) {
|
||||
let r = await fetch('/api/v1/list/' + list.id, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(list),
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
const model: List = await r.json();
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
if (avatar) {
|
||||
formData.append("avatar", avatar);
|
||||
}
|
||||
|
||||
r = await fetch(`/api/v1/list/${model.id!}/file`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function lists_add_trail(list: List, trail: Trail) {
|
||||
let model = await pb
|
||||
.collection("lists")
|
||||
.update(list.id!, { "trails+": trail.id });
|
||||
const r = await fetch('/api/v1/list/' + list.id, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
"trails+": trail.id
|
||||
}),
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function lists_remove_trail(list: List, trail: Trail) {
|
||||
let model = await pb
|
||||
.collection("lists")
|
||||
.update(list.id!, { "trails-": trail.id });
|
||||
const r = await fetch('/api/v1/list/' + list.id, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
"trails-": trail.id
|
||||
}),
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function lists_delete(list: List) {
|
||||
const r = await fetch('/api/v1/list/' + list.id, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,43 @@
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { SummitLog } from "$lib/models/summit_log";
|
||||
import { ClientResponseError } from "pocketbase";
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
|
||||
export const summitLog: Writable<SummitLog> = writable(new SummitLog(new Date().toISOString()));
|
||||
|
||||
export async function summit_logs_create(bodyParams?: { [key: string]: any; } | FormData) {
|
||||
const model = await pb
|
||||
.collection("summit_logs")
|
||||
.create<SummitLog>(bodyParams);
|
||||
export async function summit_logs_create(summitLog: SummitLog) {
|
||||
const r = await fetch('/api/v1/summit-log', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(summitLog),
|
||||
})
|
||||
|
||||
return model;
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function summit_logs_update(updatedSummitLog: SummitLog) {
|
||||
const model = await pb
|
||||
.collection("summit_logs")
|
||||
.update(updatedSummitLog.id!, updatedSummitLog);
|
||||
export async function summit_logs_update(summitLog: SummitLog) {
|
||||
const r = await fetch('/api/v1/summit-log/' + summitLog.id, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(summitLog),
|
||||
})
|
||||
|
||||
return model;
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function summit_logs_delete(id: string) {
|
||||
const success = await pb
|
||||
.collection("summit_logs")
|
||||
.delete(id);
|
||||
export async function summit_logs_delete(summitLog: SummitLog) {
|
||||
const r = await fetch('/api/v1/summit-log/' + summitLog.id, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
|
||||
return success;
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
@@ -9,25 +9,31 @@ import { summit_logs_create, summit_logs_delete, summit_logs_update } from "./su
|
||||
import { waypoints_create, waypoints_delete, waypoints_update } from "./waypoint_store";
|
||||
import { ms } from "$lib/meilisearch";
|
||||
import type { LatLng } from "leaflet";
|
||||
import { ClientResponseError } from "pocketbase";
|
||||
|
||||
export const trails: Writable<Trail[]> = writable([])
|
||||
export const trail: Writable<Trail> = writable(new Trail(""));
|
||||
|
||||
export const editTrail: Writable<Trail> = writable(new Trail(""));
|
||||
|
||||
export async function trails_index(data: { perPage: number, random?: boolean } = { perPage: 5, random: false }) {
|
||||
const response: Trail[] = (await pb.collection('trails').getList<Trail>(1, data.perPage, { expand: "category,waypoints,summit_logs", sort: data.random ? "@random" : "" })).items
|
||||
export async function trails_index(data: { perPage: number, random?: boolean, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> } = { perPage: 5, random: false, f: fetch }) {
|
||||
const r = await data.f('/api/v1/trail?' + new URLSearchParams({
|
||||
expand: "category,waypoints,summit_logs",
|
||||
sort: data.random ? "@random" : ""
|
||||
}), {
|
||||
method: 'GET',
|
||||
})
|
||||
const response = await r.json()
|
||||
|
||||
for (const trail of response) {
|
||||
setFileURLs(trail);
|
||||
if (r.ok) {
|
||||
trails.set(response.items);
|
||||
return response.items;
|
||||
} else {
|
||||
throw new ClientResponseError(response)
|
||||
}
|
||||
|
||||
trails.set(response);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function trails_search_filter(filter: TrailFilter) {
|
||||
export async function trails_search_filter(filter: TrailFilter, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
||||
let filterText: string = `distance >= ${filter.distanceMin} AND distance <= ${filter.distanceMax} AND elevation_gain >= ${filter.elevationGainMin} AND elevation_gain <= ${filter.elevationGainMax}`;
|
||||
|
||||
if (filter.category.length > 0) {
|
||||
@@ -49,18 +55,21 @@ export async function trails_search_filter(filter: TrailFilter) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const dbResponse: Trail[] = (await pb.collection('trails').getList<Trail>(1, 5, {
|
||||
filter: trailIds.map((id) => `id="${id}"`).join('||'), expand: "category,waypoints,summit_logs",
|
||||
const r = await f('/api/v1/trail?' + new URLSearchParams({
|
||||
expand: "category,waypoints,summit_logs",
|
||||
filter: trailIds.map((id) => `id="${id}"`).join('||'),
|
||||
sort: `${filter.sortOrder}${filter.sort}`
|
||||
})).items
|
||||
}), {
|
||||
method: 'GET',
|
||||
})
|
||||
const response = await r.json()
|
||||
|
||||
for (const trail of dbResponse) {
|
||||
setFileURLs(trail);
|
||||
if (r.ok) {
|
||||
trails.set(response.items);
|
||||
return response.items;
|
||||
} else {
|
||||
throw new ClientResponseError(response)
|
||||
}
|
||||
|
||||
trails.set(dbResponse);
|
||||
|
||||
return dbResponse;
|
||||
}
|
||||
|
||||
export async function trails_search_bounding_box(northEast: LatLng, southWest: LatLng, filter?: TrailFilter) {
|
||||
@@ -78,13 +87,13 @@ export async function trails_search_bounding_box(northEast: LatLng, southWest: L
|
||||
}
|
||||
}
|
||||
|
||||
const response = await ms.index("trails").search("", {
|
||||
const indexResponse = await ms.index("trails").search("", {
|
||||
filter: [
|
||||
`_geoBoundingBox([${northEast.lat}, ${northEast.lng}], [${southWest.lat}, ${southWest.lng}])`,
|
||||
filterText
|
||||
],
|
||||
});
|
||||
const trailIds = response.hits.map((h) => h.id);
|
||||
const trailIds = indexResponse.hits.map((h) => h.id);
|
||||
|
||||
if (trailIds.length == 0) {
|
||||
const currentTrails: Trail[] = get(trails);
|
||||
@@ -92,96 +101,111 @@ export async function trails_search_bounding_box(northEast: LatLng, southWest: L
|
||||
return compareObjectArrays<Trail>(currentTrails, []);
|
||||
}
|
||||
|
||||
const dbResponse: Trail[] = (
|
||||
await pb.collection("trails").getList<Trail>(1, 5, {
|
||||
filter: trailIds.map((id) => `id="${id}"`).join("||"),
|
||||
expand: "category,waypoints,summit_logs",
|
||||
sort: `+name`,
|
||||
})
|
||||
).items;
|
||||
const r = await fetch('/api/v1/trail?' + new URLSearchParams({
|
||||
filter: trailIds.map((id) => `id="${id}"`).join("||"),
|
||||
expand: "category,waypoints,summit_logs",
|
||||
sort: `+name`,
|
||||
}), {
|
||||
method: 'GET',
|
||||
})
|
||||
const response = await r.json()
|
||||
|
||||
for (const trail of dbResponse) {
|
||||
setFileURLs(trail);
|
||||
const gpxData: string = await fetchGPX(trail);
|
||||
trail.expand.gpx_data = gpxData;
|
||||
if (r.ok) {
|
||||
|
||||
for (const trail of response.items) {
|
||||
const gpxData: string = await fetchGPX(trail);
|
||||
trail.expand.gpx_data = gpxData;
|
||||
}
|
||||
|
||||
const comparison = compareObjectArrays<Trail>(get(trails), response.items)
|
||||
|
||||
trails.set(response.items);
|
||||
|
||||
return comparison;
|
||||
} else {
|
||||
throw new ClientResponseError(response)
|
||||
}
|
||||
|
||||
const comparison = compareObjectArrays<Trail>(get(trails), dbResponse)
|
||||
|
||||
trails.set(dbResponse);
|
||||
|
||||
return comparison;
|
||||
}
|
||||
|
||||
export async function trails_show(id: string, loadGPX?: boolean) {
|
||||
const response: Trail = await pb.collection('trails').getOne<Trail>(id, { expand: "category,waypoints,summit_logs" })
|
||||
export async function trails_show(id: string, loadGPX?: boolean, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
||||
const r = await f(`/api/v1/trail/${id}?` + new URLSearchParams({
|
||||
expand: "category,waypoints,summit_logs",
|
||||
}), {
|
||||
method: 'GET',
|
||||
})
|
||||
const response = await r.json()
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(response)
|
||||
}
|
||||
|
||||
if (loadGPX) {
|
||||
const gpxData: string = await fetchGPX(response);
|
||||
response.expand.gpx_data = gpxData;
|
||||
}
|
||||
|
||||
setFileURLs(response);
|
||||
|
||||
response.expand.waypoints = response.expand.waypoints || [];
|
||||
response.expand.summit_logs = response.expand.summit_logs || [];
|
||||
|
||||
response._photoFiles = [];
|
||||
|
||||
trail.set(response);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function trails_create(trail: Trail, formData: { [key: string]: any; } | FormData) {
|
||||
export async function trails_create(trail: Trail, photos: File[], gpx: File | null) {
|
||||
|
||||
if (!pb.authStore.model) {
|
||||
throw new Error("Unauthenticated");
|
||||
}
|
||||
formData.set("category", trail.expand.category!.id);
|
||||
|
||||
for (const file of trail._photoFiles) {
|
||||
formData.append("photos", file);
|
||||
}
|
||||
|
||||
for (const waypoint of trail.expand.waypoints) {
|
||||
const model = await waypoints_create({
|
||||
...waypoint,
|
||||
marker: undefined,
|
||||
});
|
||||
formData.append("waypoints", model.id!);
|
||||
trail.waypoints.push(model.id!);
|
||||
}
|
||||
for (const summitLog of trail.expand.summit_logs) {
|
||||
const model = await summit_logs_create(summitLog);
|
||||
formData.append("summit_logs", model.id!);
|
||||
trail.summit_logs.push(model.id!);
|
||||
}
|
||||
|
||||
if (!formData.get("public")) {
|
||||
formData.set("public", 0);
|
||||
trail.author = pb.authStore.model!.id
|
||||
|
||||
let r = await fetch('/api/v1/trail', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ ...trail, expand: undefined }),
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
formData.append("author", pb.authStore.model!.id);
|
||||
let model: Trail = await r.json();
|
||||
|
||||
let model = await pb
|
||||
.collection("trails")
|
||||
.create<Trail>(formData);
|
||||
|
||||
const thumbnailIndex = trail.photos.findIndex(
|
||||
(p) => p == trail.thumbnail,
|
||||
);
|
||||
let thumbnail: string | undefined = "/imgs/thumbnail.jpg";
|
||||
if (thumbnailIndex >= 0) {
|
||||
thumbnail = model.photos.at(thumbnailIndex);
|
||||
const formData = new FormData()
|
||||
if (gpx) {
|
||||
formData.append("gpx", gpx);
|
||||
}
|
||||
|
||||
model = await pb
|
||||
.collection("trails")
|
||||
.update<Trail>(model.id!, { thumbnail: thumbnail }, { expand: "category" });
|
||||
for (const photo of photos) {
|
||||
formData.append("photos", photo)
|
||||
}
|
||||
|
||||
return model;
|
||||
r = await fetch(`/api/v1/trail/${model.id!}/file`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function trails_update(oldTrail: Trail, newTrail: Trail, formData: { [key: string]: any; } | FormData) {
|
||||
export async function trails_update(oldTrail: Trail, newTrail: Trail, photos: File[], gpx: File | null) {
|
||||
|
||||
const waypointUpdates = compareObjectArrays<Waypoint>(oldTrail.expand.waypoints ?? [], newTrail.expand.waypoints ?? []);
|
||||
|
||||
@@ -190,7 +214,7 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
||||
...addedWaypoint,
|
||||
marker: undefined,
|
||||
});
|
||||
formData.append("waypoints", model.id!);
|
||||
newTrail.waypoints.push(model.id!);
|
||||
}
|
||||
|
||||
for (const updatedWaypoint of waypointUpdates.updated) {
|
||||
@@ -198,39 +222,45 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
||||
...updatedWaypoint,
|
||||
marker: undefined,
|
||||
});
|
||||
formData.append("waypoints", model.id!);
|
||||
}
|
||||
|
||||
for (const deletedWaypoint of waypointUpdates.deleted) {
|
||||
const success = await waypoints_delete(deletedWaypoint.id!);
|
||||
}
|
||||
|
||||
for (const unchangedWaypoint of waypointUpdates.unchanged) {
|
||||
formData.append("waypoints", unchangedWaypoint.id!);
|
||||
const success = await waypoints_delete(deletedWaypoint);
|
||||
}
|
||||
|
||||
const summitLogUpdates = compareObjectArrays<SummitLog>(oldTrail.expand.summit_logs ?? [], newTrail.expand.summit_logs ?? []);
|
||||
|
||||
for (const summitLog of summitLogUpdates.added) {
|
||||
const model = await summit_logs_create(summitLog);
|
||||
formData.append("summit_logs", model.id!);
|
||||
newTrail.summit_logs.push(model.id!);
|
||||
}
|
||||
|
||||
for (const updatedSummitLog of summitLogUpdates.updated) {
|
||||
const model = await summit_logs_update(updatedSummitLog);
|
||||
formData.append("summit_logs", model.id!);
|
||||
}
|
||||
|
||||
for (const deletedSummitLog of summitLogUpdates.deleted) {
|
||||
const success = await summit_logs_delete(deletedSummitLog.id!);
|
||||
const success = await summit_logs_delete(deletedSummitLog);
|
||||
}
|
||||
|
||||
for (const unchangedSummitLog of summitLogUpdates.unchanged) {
|
||||
formData.append("summit_logs", unchangedSummitLog.id!);
|
||||
let r = await fetch('/api/v1/trail/' + newTrail.id, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ ...newTrail, expand: undefined }),
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
for (const file of newTrail._photoFiles) {
|
||||
formData.append("photos", file);
|
||||
let model: Trail = await r.json();
|
||||
|
||||
const formData = new FormData()
|
||||
if (gpx) {
|
||||
formData.append("gpx", gpx);
|
||||
}
|
||||
|
||||
for (const photo of photos) {
|
||||
formData.append("photos", photo)
|
||||
}
|
||||
|
||||
const deletedPhotos = oldTrail.photos.filter(oldPhoto => !newTrail.photos.find(newPhoto => newPhoto === oldPhoto));
|
||||
@@ -239,30 +269,15 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
||||
formData.append("photos-", deletedPhoto.replace(/^.*[\\/]/, ''));
|
||||
}
|
||||
|
||||
if (formData.get("gpx").size == 0) {
|
||||
formData.delete("gpx");
|
||||
r = await fetch(`/api/v1/trail/${newTrail.id!}/file`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
if (!formData.get("public")) {
|
||||
formData.set("public", 0);
|
||||
}
|
||||
|
||||
const thumbnailIndex = newTrail.photos.findIndex(
|
||||
(p) => p == newTrail.thumbnail,
|
||||
);
|
||||
|
||||
let model = await pb
|
||||
.collection("trails")
|
||||
.update<Trail>(newTrail.id!, formData);
|
||||
|
||||
let thumbnail: string | undefined = oldTrail.thumbnail;
|
||||
if (thumbnailIndex >= 0) {
|
||||
thumbnail = model.photos.at(thumbnailIndex);
|
||||
}
|
||||
|
||||
model = await pb
|
||||
.collection("trails")
|
||||
.update<Trail>(model.id!, { thumbnail: thumbnail }, { expand: "category,waypoints,summit_logs" });
|
||||
|
||||
trail.set(model);
|
||||
|
||||
@@ -273,20 +288,24 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
||||
export async function trails_delete(trail: Trail) {
|
||||
if (trail.expand.waypoints) {
|
||||
for (const waypoint of trail.expand.waypoints) {
|
||||
waypoints_delete(waypoint.id!);
|
||||
waypoints_delete(waypoint);
|
||||
}
|
||||
}
|
||||
if (trail.expand.summit_logs) {
|
||||
for (const summit_log of trail.expand.summit_logs) {
|
||||
summit_logs_delete(summit_log.id!);
|
||||
summit_logs_delete(summit_log);
|
||||
}
|
||||
}
|
||||
|
||||
const success = await pb
|
||||
.collection("trails")
|
||||
.delete(trail.id!);
|
||||
const r = await fetch('/api/v1/trail/' + trail.id, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
|
||||
return success;
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchGPX(trail: Trail) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { regenerateInstance } from "$lib/meilisearch";
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { ClientResponseError } from "pocketbase";
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
|
||||
export type User = {
|
||||
@@ -10,20 +11,38 @@ export type User = {
|
||||
avatar?: string;
|
||||
unit?: "metric" | "imperial";
|
||||
language?: "en" | "de";
|
||||
location?: {name: string, lat: number, lon: number}
|
||||
location?: { name: string, lat: number, lon: number }
|
||||
}
|
||||
|
||||
export const currentUser: Writable<User | null> = writable<User | null>()
|
||||
|
||||
export async function users_create(user: User) {
|
||||
const model = await pb.collection('users').create({ ...user, passwordConfirm: user.password });
|
||||
const r = await fetch('/api/v1/user', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ ...user, passwordConfirm: user.password })
|
||||
})
|
||||
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
export async function login(user: User) {
|
||||
const authData = await pb.collection('users').authWithPassword(user.email ?? user.username!, user.password);
|
||||
regenerateInstance()
|
||||
const r = await fetch('/api/v1/auth/login', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(user),
|
||||
})
|
||||
|
||||
if (r.ok) {
|
||||
pb.authStore.loadFromCookie(document.cookie)
|
||||
regenerateInstance()
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
@@ -32,15 +51,27 @@ export async function logout() {
|
||||
}
|
||||
|
||||
export async function users_update(id: string, user: User | { [K in keyof User]?: User[K] } | FormData) {
|
||||
let model = await pb
|
||||
.collection("users")
|
||||
.update<User>(id, user);
|
||||
const r = await fetch('/api/v1/user', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ id: id, user: user })
|
||||
})
|
||||
|
||||
currentUser.set(model);
|
||||
if (r.ok) {
|
||||
const model = await r.json();
|
||||
currentUser.set(model);
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function users_delete(user: User) {
|
||||
let success = await pb
|
||||
.collection("users")
|
||||
.delete(user.id);
|
||||
const r = await fetch('/api/v1/user', {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({ id: user.id })
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +1,43 @@
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { Waypoint } from "$lib/models/waypoint";
|
||||
import { ClientResponseError } from "pocketbase";
|
||||
import { writable, type Writable } from "svelte/store";
|
||||
|
||||
export const waypoint: Writable<Waypoint> = writable(new Waypoint(0, 0));
|
||||
|
||||
export async function waypoints_create(bodyParams?: { [key: string]: any; } | FormData) {
|
||||
export async function waypoints_create(waypoint: Waypoint) {
|
||||
const r = await fetch('/api/v1/waypoint', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(waypoint),
|
||||
})
|
||||
|
||||
const model = await pb
|
||||
.collection("waypoints")
|
||||
.create<Waypoint>(bodyParams);
|
||||
|
||||
return model;
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function waypoints_update(updatedWaypoint: Waypoint) {
|
||||
const model = await pb
|
||||
.collection("waypoints")
|
||||
.update(updatedWaypoint.id!, updatedWaypoint);
|
||||
export async function waypoints_update(waypoint: Waypoint) {
|
||||
const r = await fetch('/api/v1/waypoint/' + waypoint.id, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(waypoint),
|
||||
})
|
||||
|
||||
return model;
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
|
||||
export async function waypoints_delete(id: string) {
|
||||
const success = await pb
|
||||
.collection("waypoints")
|
||||
.delete(id);
|
||||
export async function waypoints_delete(waypoint: Waypoint) {
|
||||
const r = await fetch('/api/v1/waypoint/' + waypoint.id, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
|
||||
return success;
|
||||
if (r.ok) {
|
||||
return await r.json();
|
||||
} else {
|
||||
throw new ClientResponseError(await r.json())
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { categories_index } from "$lib/stores/category_store";
|
||||
import { trails_index } from "$lib/stores/trail_store";
|
||||
import type { ServerLoad } from "@sveltejs/kit";
|
||||
|
||||
export const load: ServerLoad = async ({ params, locals }) => {
|
||||
await trails_index({perPage: 20, random: true})
|
||||
export const load: ServerLoad = async ({ params, locals, fetch }) => {
|
||||
await trails_index({perPage: 20, random: true, f: fetch})
|
||||
await categories_index()
|
||||
};
|
||||
13
web/src/routes/api/v1/auth/login/+server.ts
Normal file
13
web/src/routes/api/v1/auth/login/+server.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { error, json, type RequestEvent } from "@sveltejs/kit";
|
||||
|
||||
export async function POST(event: RequestEvent) {
|
||||
const data = await event.request.json()
|
||||
try {
|
||||
const r = await pb.collection('users').authWithPassword(data.email ?? data.username!, data.password);
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e);
|
||||
}
|
||||
|
||||
}
|
||||
28
web/src/routes/api/v1/list/+server.ts
Normal file
28
web/src/routes/api/v1/list/+server.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { List } from '$lib/models/list';
|
||||
import { pb } from '$lib/pocketbase';
|
||||
import { error, json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
const sort = event.url.searchParams.get('sort') ?? ""
|
||||
try {
|
||||
const r: List[] = await pb.collection('lists').getFullList<List>({
|
||||
expand: "trails",
|
||||
sort: sort,
|
||||
})
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function PUT(event: RequestEvent) {
|
||||
const data = await event.request.json();
|
||||
|
||||
try {
|
||||
const r = await pb.collection('lists').create<List>(data)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
23
web/src/routes/api/v1/list/[id]/+server.ts
Normal file
23
web/src/routes/api/v1/list/[id]/+server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { error, json, type RequestEvent } from "@sveltejs/kit";
|
||||
import type { List } from "postcss/lib/list";
|
||||
|
||||
export async function POST(event: RequestEvent) {
|
||||
const data = await event.request.json()
|
||||
|
||||
try {
|
||||
const r = await pb.collection('lists').update<List>(event.params.id as string, data)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(event: RequestEvent) {
|
||||
try {
|
||||
const r = await pb.collection('lists').delete(event.params.id as string)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
13
web/src/routes/api/v1/list/[id]/file/+server.ts
Normal file
13
web/src/routes/api/v1/list/[id]/file/+server.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { error, json, type RequestEvent } from "@sveltejs/kit";
|
||||
import type { List } from "postcss/lib/list";
|
||||
|
||||
export async function POST(event: RequestEvent) {
|
||||
const data = await event.request.formData()
|
||||
try {
|
||||
const r = await pb.collection("lists").update<List>(event.params.id as string, data,);
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
14
web/src/routes/api/v1/summit-log/+server.ts
Normal file
14
web/src/routes/api/v1/summit-log/+server.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { SummitLog } from '$lib/models/summit_log';
|
||||
import { pb } from '$lib/pocketbase';
|
||||
import { error, json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function PUT(event: RequestEvent) {
|
||||
const data = await event.request.json();
|
||||
|
||||
try {
|
||||
const r = await pb.collection('summit_logs').create<SummitLog>(data)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
23
web/src/routes/api/v1/summit-log/[id]/+server.ts
Normal file
23
web/src/routes/api/v1/summit-log/[id]/+server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { SummitLog } from "$lib/models/summit_log";
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { error, json, type RequestEvent } from "@sveltejs/kit";
|
||||
|
||||
|
||||
export async function POST(event: RequestEvent) {
|
||||
const data = await event.request.json()
|
||||
try {
|
||||
const r = await await pb.collection("summit_logs").update<SummitLog>(event.params.id as string, data);
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(event: RequestEvent) {
|
||||
try {
|
||||
const r = await pb.collection('summit_logs').delete(event.params.id as string)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
30
web/src/routes/api/v1/trail/+server.ts
Normal file
30
web/src/routes/api/v1/trail/+server.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { Trail } from '$lib/models/trail';
|
||||
import { pb } from '$lib/pocketbase';
|
||||
import { error, json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
const page = event.url.searchParams.get("page") ?? "0";
|
||||
const perPage = event.url.searchParams.get("per-page") ?? "5";
|
||||
const expand = event.url.searchParams.get("expand") ?? ""
|
||||
const sort = event.url.searchParams.get("sort") ?? ""
|
||||
const filter = event.url.searchParams.get("filter") ?? "";
|
||||
|
||||
try {
|
||||
const r = await pb.collection('trails')
|
||||
.getList<Trail>(parseInt(page), parseInt(perPage), { expand: expand ?? "", sort: sort ?? "", filter: filter ?? "" })
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(event: RequestEvent) {
|
||||
const data = await event.request.json();
|
||||
try {
|
||||
const r = await pb.collection('trails').create<Trail>(data)
|
||||
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
35
web/src/routes/api/v1/trail/[id]/+server.ts
Normal file
35
web/src/routes/api/v1/trail/[id]/+server.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { Trail } from "$lib/models/trail";
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import { error, json, type RequestEvent } from "@sveltejs/kit";
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
const expand = event.url.searchParams.get("expand") ?? ""
|
||||
|
||||
try {
|
||||
const r = await pb.collection('trails')
|
||||
.getOne<Trail>(event.params.id as string, { expand: expand ?? "" })
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function POST(event: RequestEvent) {
|
||||
const data = await event.request.json()
|
||||
try {
|
||||
const r = await pb.collection("trails").update<Trail>(event.params.id as string, data, { expand: "category,waypoints,summit_logs" });
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(event: RequestEvent) {
|
||||
try {
|
||||
const r = await pb.collection('trails').delete(event.params.id as string)
|
||||
return json(r);
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user