 ! DOMAIN MODEL
 ! ! !
 
-TUPLE: paste id summary author mode date contents annotations ;
-
-\ paste "PASTE"
+TUPLE: entity id summary author mode date contents ;
+
+entity f
 {
     { "id" "ID" INTEGER +db-assigned-id+ }
-    { "summary" "SUMMARY" { VARCHAR 256 } +not-null+ }
-    { "author" "AUTHOR" { VARCHAR 256 } +not-null+ }
-    { "mode" "MODE" { VARCHAR 256 } +not-null+ }
-    { "date" "DATE" DATETIME +not-null+ , }
-    { "contents" "CONTENTS" TEXT +not-null+ }
-} define-persistent
-
-: <paste> ( id -- paste )
-    \ paste new
-        swap >>id ;
-
-: pastes ( -- pastes )
-    f <paste> select-tuples ;
-
-TUPLE: annotation aid id summary author mode contents date ;
-
-annotation "ANNOTATION"
-{
-    { "aid" "AID" INTEGER +db-assigned-id+ }
-    { "id" "ID" INTEGER +not-null+ }
     { "summary" "SUMMARY" { VARCHAR 256 } +not-null+ }
     { "author" "AUTHOR" { VARCHAR 256 } +not-null+ }
     { "mode" "MODE" { VARCHAR 256 } +not-null+ }


: <new-annotation-action> ( -- action )
    <page-action>
        [ validate-paste ] >>validate

        [ "id" param "$pastebin/paste" <id-redirect> ] >>display

        [
            f f <annotation>
            {
                [ deposit-paste-slots ]
                [ { "id" } deposit-slots ]
                [ insert-tuple ]
                [
                    ! Add anchor here
                    id>> "$pastebin/paste" <id-redirect>
                ]
            } cleave
        ] >>submit ;

: <delete-annotation-action> ( -- action )
    <action>
        [ { { "aid" [ v-number ] } } validate-params ] >>validate

        [
            f "aid" value <annotation> select-tuple
            [ delete-tuples ]
            [ id>> "$pastebin/paste" <id-redirect> ]
            bi
        ] >>submit ;


        { "captcha" [ v-captcha ] }
    } validate-params ;

: deposit-entity-slots ( tuple -- )
    now >>date
    { "summary" "author" "mode" "contents" } deposit-slots ;

