package com.couchbase.devxp.updownvote;

import com.couchbase.lite.CouchbaseLiteException;
import com.couchbase.lite.Database;
import com.couchbase.lite.Document;
import com.couchbase.lite.Query;

public class Presentation {
    // HINT create a property in the presentations so you can find them among the objects
    public static final String TYPE = "presentation";

    // TODO Create fields for createdAt, upVotes, downVotes, title

    public static Query findAll(Database database) {
        // TODO create a view with a map function listing all the presentations in the database
        return null;
    }

    public static Presentation from(Document document) {
        // TODO create a presentation object from the document passed
        // HINT make sure to save of the document to enable updating later
        return null;
    }

    public Presentation(Database database) {
        // TODO initialzie the fields
        // TODO save of a reference to the database used
    }

    public void save() throws CouchbaseLiteException {
        // TODO save a document to the database
        // TODO update a document if it has been saved before
        // HINT this needs a reference to the original document for revision, key, etc.
    }
}

@@ -190,16 +190,40 @@
 Query;%0A%0A
+import java.util.Date;%0A%0A
 public c
@@ -387,16 +387,191 @@
 tion%22;%0A%0A
+    private Date createdAt;%0A    private int upVotes;%0A    private int downVotes;%0A    private String title;%0A    private Document sourceDocument;%0A    private Database database;%0A%0A
     // T
@@ -1349,16 +1349,16 @@
  before%0A
-
         
@@ -1442,11 +1442,793 @@
 c.%0A    %7D
+%0A%0A    public Date getCreatedAt() %7B%0A        return createdAt;%0A    %7D%0A%0A    public void setCreatedAt(Date createdAt) %7B%0A        this.createdAt = createdAt;%0A    %7D%0A%0A    public int getUpVotes() %7B%0A        return upVotes;%0A    %7D%0A%0A    public void setUpVotes(int upVotes) %7B%0A        this.upVotes = upVotes;%0A    %7D%0A%0A    public int getDownVotes() %7B%0A        return downVotes;%0A    %7D%0A%0A    public void setDownVotes(int downVotes) %7B%0A        this.downVotes = downVotes;%0A    %7D%0A%0A    public String getTitle() %7B%0A        return title;%0A    %7D%0A%0A    public void setTitle(String title) %7B%0A        this.title = title;%0A    %7D%0A%0A    public Document getSourceDocument() %7B%0A        return sourceDocument;%0A    %7D%0A%0A    public void setSourceDocument(Document sourceDocument) %7B%0A        this.sourceDocument = sourceDocument;%0A    %7D
 %0A%7D%0A

add Presentation Getters and Setters