all repos — litestore @ 343ed9059c45739848f7c3215b4e88cde40b2ba5

A minimalist nosql document store.

app/js/models.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
(function(){
  window.Page = {};
  window.Info = {};
  window.Doc = {};
  
  Page.get = function(id) {
    var content = m.prop("");
    return m.request({
        method: "GET", 
        url: "md/"+id+".md",
        deserialize: function(value) {return value;}
      }).then(function(content){ return marked(content);});
  };
  
  Info.get = function(){
    var content = m.prop("");
    return m.request({
        method: "GET", 
        url: "/v1/info"
      }).then(content);
  };
  
  Doc.getByTag = function(tag) {
    var docs = m.prop("");
    return m.request({
        method: "GET", 
        url: "/v1/docs?contents=false&tags="+tag
      }).then(docs);
  };
  
  Doc.get = function(id) {
    var doc = m.prop("");
    return m.request({
        method: "GET", 
        url: "/v1/docs/"+id+"?raw=true"
      }).then(doc);
  };
  
  Doc.put = function(doc){
    xhrcfg = u.getContentType(doc);
    return m.request({
        method: "PUT", 
        url: "/v1/docs/"+doc.id,
        data: doc.data,
        serialize: function(data){return data;},
        config: xhrcfg
      });
    };
}());