Adds collections and types

This commit is contained in:
2025-05-27 18:07:26 -07:00
parent b96fe1371e
commit f61ebef59a
5 changed files with 260 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = new Collection({
"createRule": null,
"deleteRule": null,
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text3208210256",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"autogeneratePattern": "",
"hidden": false,
"id": "text1579384326",
"max": 0,
"min": 0,
"name": "name",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
},
{
"cascadeDelete": false,
"collectionId": "_pb_users_auth_",
"hidden": false,
"id": "relation3479234172",
"maxSelect": 1,
"minSelect": 0,
"name": "owner",
"presentable": false,
"required": false,
"system": false,
"type": "relation"
},
{
"hidden": false,
"id": "autodate2990389176",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate3332085495",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}
],
"id": "pbc_2270728936",
"indexes": [],
"listRule": null,
"name": "campaigns",
"system": false,
"type": "base",
"updateRule": null,
"viewRule": null
});
return app.save(collection);
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2270728936");
return app.delete(collection);
})

View File

@@ -0,0 +1,80 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = new Collection({
"createRule": null,
"deleteRule": null,
"fields": [
{
"autogeneratePattern": "[a-z0-9]{15}",
"hidden": false,
"id": "text3208210256",
"max": 15,
"min": 15,
"name": "id",
"pattern": "^[a-z0-9]+$",
"presentable": false,
"primaryKey": true,
"required": true,
"system": true,
"type": "text"
},
{
"cascadeDelete": true,
"collectionId": "pbc_2270728936",
"hidden": false,
"id": "relation1542800728",
"maxSelect": 1,
"minSelect": 0,
"name": "field",
"presentable": false,
"required": true,
"system": false,
"type": "relation"
},
{
"hidden": false,
"id": "json2918445923",
"maxSize": 0,
"name": "data",
"presentable": false,
"required": false,
"system": false,
"type": "json"
},
{
"hidden": false,
"id": "autodate2990389176",
"name": "created",
"onCreate": true,
"onUpdate": false,
"presentable": false,
"system": false,
"type": "autodate"
},
{
"hidden": false,
"id": "autodate3332085495",
"name": "updated",
"onCreate": true,
"onUpdate": true,
"presentable": false,
"system": false,
"type": "autodate"
}
],
"id": "pbc_3332084752",
"indexes": [],
"listRule": null,
"name": "documents",
"system": false,
"type": "base",
"updateRule": null,
"viewRule": null
});
return app.save(collection);
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_3332084752");
return app.delete(collection);
})

View File

@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2270728936")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "@request.auth.id = owner.id",
"listRule": "@request.auth.id = owner.id",
"updateRule": "@request.auth.id = owner.id",
"viewRule": "@request.auth.id = owner.id"
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2270728936")
// update collection data
unmarshal({
"createRule": null,
"deleteRule": null,
"listRule": null,
"updateRule": null,
"viewRule": null
}, collection)
return app.save(collection)
})

View File

@@ -0,0 +1,58 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_3332084752")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "@request.auth.id = campaign.owner.id",
"listRule": "@request.auth.id = campaign.owner.id",
"updateRule": "@request.auth.id = campaign.owner.id",
"viewRule": "@request.auth.id = campaign.owner.id"
}, collection)
// update field
collection.fields.addAt(1, new Field({
"cascadeDelete": true,
"collectionId": "pbc_2270728936",
"hidden": false,
"id": "relation1542800728",
"maxSelect": 1,
"minSelect": 0,
"name": "campaign",
"presentable": false,
"required": true,
"system": false,
"type": "relation"
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_3332084752")
// update collection data
unmarshal({
"createRule": null,
"deleteRule": null,
"listRule": null,
"updateRule": null,
"viewRule": null
}, collection)
// update field
collection.fields.addAt(1, new Field({
"cascadeDelete": true,
"collectionId": "pbc_2270728936",
"hidden": false,
"id": "relation1542800728",
"maxSelect": 1,
"minSelect": 0,
"name": "field",
"presentable": false,
"required": true,
"system": false,
"type": "relation"
}))
return app.save(collection)
})

10
src/lib/types.ts Normal file
View File

@@ -0,0 +1,10 @@
export type Campaign = {
id: string;
name: string;
};
export type Document = {
id: string;
campaign: Campaign;
data: {};
};