Below is a overview Go APIs, see auto generated go documentation

Table of contents
  1. Fetch contents
    1. Fetch a content
    2. Fetch List
    3. Fetch subtree
    4. Fetch user/role
  2. Operate contents
  3. Permission
  4. Database
    1. Conditions
    2. Queries
    3. Data operations
  5. Utilities
  6. Log & Debug

Fetch contents

package core/query

Note: in all queries, the condition syntax as below is used

ids := []int{3, 4, 5, 7, 9, 10}
condition := db.Cond("id", ids).Cond("l.depth", 2).Cond("author", 1).Sortby("modified desc").Limit(0, 2)

Fetch a content

Function Description
FetchByID Fetch a content by id
FetchByCID Fetch a content by content id
Fetch Fetch a content by condition
FetchByUID Fetch a content by unique id
FetchByCUID Fetch a content by content unique id

Fetch List

Function Description
SubList Fetch content list under a content, with permission considered
ListWithUser Fetch content list with permission considered
Children Fetch children(direct children) with permission considered
List Fetch list by conditions(without permission considered)

Fetch subtree

Function Description
SubTree Fetch sub tree of a content

Fetch user/role

Function Description
UserRole Fetch users, roles based on condition

Operate contents

package core/handler

Manipulate content

Function Description
Create Create content
Update Update a content
Move Move a content location
DeleteByID Delete a content by location id
DeleteByCID Delete a content by content id
DeleteByContent Delete a content

User

Function Description
CanLogin Check if a user can login or not
Enable Enable/Disable a user

Permission

package core/permission

Function Description
HasAccessTo Check if a user can accces to a operation
CanRead Check if a user can read a content
CanUpdate Check if a user can update a content
CanDelete Check if a user can delete a content
Fetch policies and access  
GetUserAccess Get user limit list
GetUserPolicies Get user polices
Operations  
AssignToUser Assign a role to a user
RemoveAssignment Remove the assignment of user role

Database

package core/db

Conditions

A condition includes information of field, operator and value(eg. “id > “, 10). Operator can be ignored if it’s ‘=’ or ‘in’. Typical values are like 1(int), “hello”(string), or int/string slices(in will be used when querying), or datetime. So the value should be a baisc types or struct implementing database.sql.driver.Valuer.

Supported operators: ">", ">=", "<", "==", "<=", "!=", "=", "in", "like".

Note: “==” is for join between 2 targets.

It uses object-method style to build logical conditions.

//Below 2 are the same. Note: when using 'in/like' there should be a space before the operator
db.Cond("id>", ids)
db.Cond("id >", ids)

//id equals 3
db.Cond("id", 3)

//id in 1, 3
db.Cond("id", []int{1, 3})

//id in 1, 3 and author is 1
db.Cond("id", []int{1, 3}).Cond("author", 1)

Check here to see typical condition examples.

Function Description
Cond Create a condition
EmptyCond Empty condition
TrueCond Always true
FalseCond Always false
Condition struct  
Cond Same as And&Cond combined
And Same as And with itself as first parameter
Or Same as Or with itself as first parameter
Sortby Sort by
Limit Limit
WithCount Always include count in result regarless limit

Queries

There are 2 types of entities: content entities and normal entities. A content entity can be a combination from different tables. A typical normal entity is from a table.

Most of content related query can be done via apis in core/query.

If you want to fetch normal table data, BindEntity is the way to go. You can create a struct or anonymous struct to bind into. There is also a db.Datamap and DatamapList which can be used for binding entities to a maplist or map. Check BindEntity link in below table to see examples.

Function Description
BindContent Bind content(s) with a condition
CountContent Count content(s) with a condition
BindEntity Bind entity(s) with a condition
Count Count entity with a condition
BindContentWithQuery Bind conentent(s) with a query
BindEntityWithQuery Bind conentent(s) with a query

Data operations

Below are low level data operations. Content manipulation normally is done via apis in core/handler since they includes validation, permission check, relation cache update, versioning, etc.

Function Description
Insert Insert a record
Update Update a record
Delete Delete a record

Utilities

package core/util

Log & Debug

package core/log