Skip to content
Derek Tsui edited this page Jun 1, 2015 · 17 revisions
Action Endpoint Request Type
1. Add Story /stories/ POST
2. Delete Story /stories/<id> DELETE
3. Update Story /stories/<id> PATCH
4. Get Stories /stories/<id> GET
5. Search Story /stories/search POST

Working with Documents

Add Story (POST /stories/)

db.s_add(title, text, parent, meta)

  • title (string): Send the title of the snippet.
  • text (string): Send the snippet of text.
  • parent (int): Send the ID of the parent node that this node is branching from.
  • meta (dictionary {"author", "tags"}):
    • author (string): Send the username of the author
    • tags (array of strings): Relevant tags

Response

  • ID of the created node (int)

Get Story (GET /stories/<id>)

db.s_get(i)

  • i (int): ID of the node

Response

  • mongodb document (dictionary) containing the story {"_id","title","text","parent","children","author","time","tags"}

db.s_getall()

No parameters

Response

  • list of mongodb documents (dictionary) containing all stories that HAVE NO PARENTS {"_id","title","text","parent","children","author","time","tags"}

Update Stories (PATCH /stories/<id>)

db.s_edit(i, title, text, parent, meta)

fields to be unchanged should be left as None, except meta, which should be an empty list: []

  • i (int): ID of the node
  • title (string): the title of the snippet.
  • text (string): the snippet of text.
  • parent (int): the ID of the parent node that this node is branching from.
  • meta (dictionary {"author", "tags"}):
    • author (string): Send the username of the author
    • tags (array of strings): Relevant tags

Response

  • None

Search Stories (POST /stories/search)

db.s_search(term, context)

  • term (string): Search query
  • context (string): The document field to be searched: "title", "author", "text", "tags"
    • authors (list of strings): A list of the authors by username.
    • tags (list of strings): A list of the search tags.
    • timeframe (?)
  • options
    • max (int): The max number of stories to send back not yet implemented

Response

  • results (list of nodes): list of mongodb documents (dictionary) containing queried stories