Dbquity model Examples

page modified: 2024/10/03 12:18:58

HelloWorld

site HelloWorld
    origin: model.dbquity.com/examples
    version: 1.0.0
    description:
        "Hello World", says Dbquity.
        Illustrating site, class, invariant, area, and multiline.
    class Period
        description:
            This Period class comprises the Start, Days and End fields to
            capture an interval of a certain number of days starting and ending
            at certain dates.
            It uses the invariant property to declare the formula that ties
            together these three fields.
        date Start                  # initializes to today() by default
        integer Days
        date End
        # when a user changes one value, Dbquity seeks to update another as
        # needed to satisfy the invariant
        invariant:                                    
            Start + Days = End and Start <= End

    area Welcome
        Period Meeting
        text Greeting
            multiline
            placeholder:
                "type a few kind words here, please
                (you may use emojiis 👌)"

download HelloWorld.dbquity HelloWorld.v1.0.0.dbquity-site.bin
HelloWorld.v1.0.0.dbquity-site.txt

ShoppingList

site ShoppingList
    origin:                     model.dbquity.com/examples
    version:                    1.0.0
    area Setup
        importance:             additional
        entity Unit
            collection:         Units
            text Name
                importance:     promoted
            identity:           Name
            text Description
                multiline
            decimal DefaultAmount
        entity Item
            collection:         Items
            text Name
                importance:     promoted
            identity:           Name
            text Description
                multiline
            decimal DefaultAmount
                default:        DefaultUnit.DefaultAmount
            link DefaultUnit
                entity:         Unit
    area Shopping
        entity List
            importance:         promoted
            collection:         Lists
            decimal Progress
                percent
                expression:
                    if (n: (tobuy: List@ToBuy).count()) then
                        (100 * tobuy.count(Fulfillment >= Amount) / n)
        association ToBuy
            end List
            end Item
                multiplicity:   1..*
            decimal Amount
                default:        Item.DefaultAmount
            link Unit
                default:        Item.DefaultUnit
            decimal Fulfillment
download ShoppingList.dbquity
ShoppingList.dbquity-data
ShoppingList.v1.0.0.dbquity-site.bin
ShoppingList.v1.0.0.dbquity-site.txt

RollDice

download RollDice.dbquity
RollDice.dbquity-test
RollDice.v1.0.0.dbquity-site.bin
RollDice.v1.0.0.dbquity-site.txt

These notes explain the idea of behavior and steps using the RollDice example.

Moderated Chat

site ModeratedChat
    origin: model.dbquity.com/examples
    version: 1.0.0
    profiles: Moderator
    area Chat
        permissions:
            view|create by *
            update|delete by self.createdby as *
            view|delete by Moderator
        entity Message
            collection: Messages
            text By
                expression: createdby.identity
            text Text
            text Saved
                expression: lastsaved

ModeratedChat illustrates the use of a Moderator profile and the permissions property to allow

download ModeratedChat.dbquity ModeratedChat.v1.0.0.dbquity-site.bin
ModeratedChat.v1.0.0.dbquity-site.txt