摘要:[Mongodb] Mongolab use RESTful API
Mongodb 雲端版本目前有滿多, 目前使用的是 Mongolab , 它有免費0.5G的空間可以註冊使用,
可以使用 support mongodb Tools 來管理db , 也可以利用browser 來做基本的設定調整,
而且它支援 RESTful API 的服務 , 只要能送HttpRequest 就可以存取db的資料,
使用非常簡單 , 首先取得你的api key
https://api.mongolab.com/api/1/databases?apiKey=<your-api-key>
透過api key , 服務就能識別你的mongo server ,
Database list
https://api.mongolab.com/api/1/databases?apiKey=<your-api-key>
Collection list
https://api.mongolab.com/api/1/databases/<your-databasename>/collections?apiKey=<your-api-key>
Documents of Collection
https://api.mongolab.com/api/1/databases/<your-databasename>/collections/<your-databasename>?apiKey=<your-api-key>
而且,API 服務還有支援Querystring filter , 參數的value 可以下JSON格式的值!!
Optional parameters (MongoDB reference):
-
q=<query>- restrict results by the specified JSON query -
c=true- return the result count for this query -
f=<set of fields>- specify the set of fields to include or exclude in each document (1 - include; 0 - exclude) -
fo=true- return a single document from the result set (same as findOne() using the mongo shell -
s=<sort order>- specify the order in which to sort each specified field (1- ascending; -1 - descending) -
sk=<num results to skip>- specify the number of results to skip in the result set; useful for paging -
l=<limit>- specify the limit for the number of results (default is 1000)
Excemple :
https://api.mongolab.com/api/1/databases/<your-databasename>/collections/<your-databasename>?apiKey=<your-api-key>&q={"UserName":"ryan39"}&l=100
Reference :
https://mongolab.com
http://docs.mongolab.com/restapi/