Documentation for the Codomat

Social Network

Jump to Section
Entity posts has the fields
    author text timestamp replyto
.

Entity follows has the fields
    follower followed timestamp
.

# users who the authenticated user follows
Derived myfollows
    uses follows
    is record.followed for record in follows if record.follower = current_user.id
.

# posts relevant to authenticated user
Derived myfeed
    uses posts
    is record for record in posts if current_user.id = record.author or record.author in myfollows
.

# enforce correct authorship
Restrict on create posts
    enforce author = current_user.id
    enforce timestamp = now
.

# only alter your own posts
Restrict on modify and delete posts
    ensure record.author = current_user.id
.

# enforce correct followship
Restrict on create follows
    enforce follower = current_user.id
    enforce timestamp = now
.

# only alter your own follows
Restrict on modify and delete follows
    ensure record.author = current_user.id
.