create_collection
Create a new collection in PocketBase with defined fields, access rules, and configuration options for organizing database records.
Instructions
Create a new collection in PocketBase
Input Schema
Name | Required | Description | Default |
---|---|---|---|
createRule | No | Rule for creating records | |
deleteRule | No | Rule for deleting records | |
fields | Yes | Collection fields configuration | |
indexes | No | Collection indexes | |
listRule | No | Rule for listing records | |
name | Yes | Collection name | |
passwordAuth | No | Password authentication settings for auth collections | |
type | No | Collection type (base, auth, view) | base |
updateRule | No | Rule for updating records | |
viewQuery | No | SQL query for view collections | |
viewRule | No | Rule for viewing records |
Input Schema (JSON Schema)
{
"properties": {
"createRule": {
"description": "Rule for creating records",
"type": "string"
},
"deleteRule": {
"description": "Rule for deleting records",
"type": "string"
},
"fields": {
"description": "Collection fields configuration",
"items": {
"properties": {
"autogeneratePattern": {
"description": "Pattern for autogenerating field values (for text fields)",
"type": "string"
},
"cascadeDelete": {
"description": "Whether to delete related records when the parent is deleted",
"type": "boolean"
},
"collectionId": {
"description": "Target collection ID for relation fields",
"type": "string"
},
"hidden": {
"description": "Whether the field is hidden in the UI",
"type": "boolean"
},
"id": {
"description": "Unique identifier for the field",
"type": "string"
},
"max": {
"description": "Maximum text length or numeric value",
"type": "number"
},
"maxSelect": {
"description": "Maximum number of relations or select options (1 for single relation, > 1 for multiple)",
"type": "number"
},
"min": {
"description": "Minimum text length or numeric value",
"type": "number"
},
"name": {
"description": "Field name",
"type": "string"
},
"onCreate": {
"description": "Whether to set date on record creation (for autodate fields)",
"type": "boolean"
},
"onUpdate": {
"description": "Whether to update date on record update (for autodate fields)",
"type": "boolean"
},
"pattern": {
"description": "Validation regex pattern for text fields",
"type": "string"
},
"presentable": {
"description": "Whether the field can be used as a presentable field in the UI",
"type": "boolean"
},
"required": {
"description": "Whether the field is required",
"type": "boolean"
},
"system": {
"description": "Whether this is a system field",
"type": "boolean"
},
"type": {
"description": "Field type",
"enum": [
"text",
"number",
"bool",
"email",
"url",
"date",
"select",
"relation",
"file",
"json",
"editor",
"autodate"
],
"type": "string"
},
"unique": {
"description": "Whether the field should have unique values",
"type": "boolean"
},
"values": {
"description": "Predefined values for select fields (direct property)",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"name",
"type"
],
"type": "object"
},
"type": "array"
},
"indexes": {
"description": "Collection indexes",
"items": {
"type": "string"
},
"type": "array"
},
"listRule": {
"description": "Rule for listing records",
"type": "string"
},
"name": {
"description": "Collection name",
"type": "string"
},
"passwordAuth": {
"description": "Password authentication settings for auth collections",
"properties": {
"enabled": {
"type": "boolean"
},
"identityFields": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"type": {
"default": "base",
"description": "Collection type (base, auth, view)",
"enum": [
"base",
"auth",
"view"
],
"type": "string"
},
"updateRule": {
"description": "Rule for updating records",
"type": "string"
},
"viewQuery": {
"description": "SQL query for view collections",
"type": "string"
},
"viewRule": {
"description": "Rule for viewing records",
"type": "string"
}
},
"required": [
"name",
"fields"
],
"type": "object"
}