Create a new app. This is not the most elegant way to create a collection, it's better to use Collection.fromDefinition
the app
the collection definition
Use a "definition object" to describe the shape and behavior of the collection.
Example:
import {
App,
Collection,
FieldTypes,
FieldDefinitionHelper as field,
Policies,
} from "sealious";
const app = new App();
Collection.fromDefinition(
app,
{
name: "seals",
fields: [
field("name", FieldTypes.Text),
field("age", FieldTypes.Int, { min: 0 }),
],
policy: {
show: Policies.Public,
delete: Policies.Noone,
},
});
the collection read from definition will be attached to this app
the definition of the appliaction, containing the fields and policies
the app
stores the calculated fields of the collection
the collection definition
An arbitrary value that can be use by front-ends to e.g. format forms for given collection in a specific way
Stores all the fields in the given collection. Does not store values of those fields.
This is a read-only property. If you want to change fields in an existing collection, use Collection.addField
Used while creating a REST API documentation for your app
The name of the collection. This is used as the part of it's URL in the REST API
stores the special filtes attached to this collection
stores Policies for some of the possible ActionNames. If no policy is specified for a given action, the policy under the default
key is used.
Adds a field to collection. It's usually not necessary, because you can add all the necessary fields while creating the collection.
the field definition
Add special filters to the collection
the filters to add
Throws if a given ActionName is not allowed to be performed on a given Item under given context
the context
the action name
the item (pass undefined
if checking actions like create
as then there's no item to check on)
Gets the aggregation stages that filter the resources based on Policies, filters, search params and named filters. Returns a mongo pipeline. This is done in order to avoid having to manually check each item returned from the database
the context
the ActionName
query params - e.g. parsed from a REST GET request
the filter object that can contain filter values for any of the fields in the collection
the search string
deprecated
names of any named filters that should be applied to the query
Return a named filter from the collection
the name of the filter
Get Policy for a given ActionName
the action name
Takes a db entry of an item and formats it so it can be presented to the user
the context
the raw db entry
the formats for some/all/none of the fields
whether or not to compute some/all of the fields
Return the specification of the collection to be returned when generating the docs for the REST API
the human-readable description of the collection
Set a policy for given actions
an object that maps a given ActionName to a Policy. Not all action names have to be mapped to a policy. default
policy can be provided and it will be used when performing an action with an unspecified policy.
Generated using TypeDoc
Creates a collection. All collections are automatically served via the REST API, with permissions set by the Policies