Get

The Get permissions control how a user can retrieve data from a specific collection. For instance, in the case of the "todos" collection, these permissions are designed to ensure that users can only access their own data. Here's how different properties in the "get" permissions work:

{
	"collections": {
		"todos": {
			"schema": {...},
			"permissions": {
				"user": {
                    "get": {
                        "pick": ["title"],
                        "omit": ["user"],
                        "q": {
                            "user": "$.auth._id"
                        },
                        "project": [
                            "title"
                        ],
                        "pagination": {
                            "limit": 15,
                            "max": 15,
                            "sort": {
                                "_id": 1
                            }
                        }
				    }
                }
			}
		}
	}
}

pick This property specifies the fields to be included in the query result

omit The "omit" property removes specific fields from the query result.

q This property attaches a query filter to the request. In this example, it ensures that the user can only retrieve their own todos by filtering based on the user's ID, which is taken from the authentication context (`$.auth._id`).

project The "project" property allows the user to specify which fields to include in the query results. In this case, only the "title" field of the todos will be included in the results.

pagination This property defines how the query results are paginated. The default limit is set to 15, meaning only 15 results will be returned at a time. Users can set a custom "limit" in the query string, but the maximum limit is 15 to prevent excessive data load. If no limit is set, all documents would be fetched, which can be slow and inefficient. The "sort" property ensures that the results are sorted by the "_id" field in ascending order.

Edit this page on Github
© 2025 kav3.com. Crafted with and dedication.