kule

?REST interface for MongoDB.

  • 所有者: fatiherikli/kule
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Simple REST Interface for MongoDB.

Kule is a REST interface for MongoDB. You can use kule as a temporary backend for your backend needed apps.

Requirements

  • Bottle
  • Pymongo

Installation

pip install kule

Usage

python -m kule --database foo --collections users,documents

That's all.

Kule

Now you can interact with your API., Method, Path, Action, -------------, ---------------, ------------------------------, GET, /users, Returns all records. You can give limit and offset parameters to paginate records., GET, /users/:id, Returns a single document, POST, /users, Creates a new document, PUT, /users/:id, Replaces an existing document, PATCH, /users/:id, Updates a document, DELETE, /users/:id, Removes an existing document, ### Customization

You can customize your API response for your requirements.
For example, you can provide authentication method.

Example

You can override an existing endpoint.

from kule import Kule

class MyKule(Kule):
    def delete_detail(self, collection, pk):
        return self.not_implemented()

Magical method names ...

You can override specific endpoint with kule's magical methods.

from kule import Kule

class MyKule(Kule):
    def get_users_list(self, collection):
        return ["merhaba", "hello", "hola"]

Building custom bundle

Also there is a way to build customized bundles.

from kule import Kule

class MyKule(Kule):
    def build_users_bundle(self, user):
        first_name, last_name = user.get("full_name").split()
        return {"first_name": first_name, 
                "last_name": last_name}

Starting app

mykule = MyKule(database="foo")
mykule.run()

Using with Backbone.js

You have to override the parse method of collections. Because models listing
on objects key.

Backbone.Collection.prototype.parse = function(data) {
    return data.objects ? data.objects : data;
};

// examples
var Document = Backbone.Model.extend({
    urlRoot: "http://localhost:8000/documents", // Supports CORS
    idAttribute: "_id"
});
var Documents = Backbone.Collection.extend({
    model: Document,
    url: "http://localhost:8000/documents"
});

// lets play
var _document = new Document({"title": "hello"});
_document.save()

_document.on('reset', function () {
    console.log(_document.id);
})

主要指標

概覽
名稱與所有者fatiherikli/kule
主編程語言Python
編程語言Python (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2013-04-02 21:59:29
推送於2021-04-07 21:27:41
最后一次提交2019-01-02 02:09:25
發布數0
用户参与
星數490
關注者數18
派生數34
提交數66
已啟用問題?
問題數5
打開的問題數4
拉請求數4
打開的拉請求數2
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?