All Projects → fomenyesu → Egg Mongodb Example

fomenyesu / Egg Mongodb Example

a example of eggjs, mongodb, restful api and other stuff made it work...

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Egg Mongodb Example

egg-session
session plugin for egg
Stars: ✭ 48 (-60.98%)
Mutual labels:  egg-plugin
Egg Valid
👮Validation plugin for eggjs
Stars: ✭ 10 (-91.87%)
Mutual labels:  egg-plugin
Egg Mongo Native
MongoDB egg.js plugin using native driver.
Stars: ✭ 69 (-43.9%)
Mutual labels:  egg-plugin
Egg Mysql
MySQL plugin for egg
Stars: ✭ 276 (+124.39%)
Mutual labels:  egg-plugin
Egg Restfulapi
🏅 基于Egg.js 2.0 & {mongoose,jwt}RESTful API 模板,用于快速集成开发RESTful前后端分离的服务端。
Stars: ✭ 524 (+326.02%)
Mutual labels:  egg-plugin
Egg Cancan
cancancan like authorization plugin for Egg.js
Stars: ✭ 47 (-61.79%)
Mutual labels:  egg-plugin
egg-view-vue-ssr
Egg Vue Server Side Render (SSR) Plugin
Stars: ✭ 90 (-26.83%)
Mutual labels:  egg-plugin
Egg Passport
passport plugin for egg
Stars: ✭ 98 (-20.33%)
Mutual labels:  egg-plugin
Egg Sequelize
Sequelize for Egg.js
Stars: ✭ 540 (+339.02%)
Mutual labels:  egg-plugin
Egg View React Ssr
Egg React Server Side Render (SSR) Plugin
Stars: ✭ 55 (-55.28%)
Mutual labels:  egg-plugin
Egg Graphql
Stars: ✭ 345 (+180.49%)
Mutual labels:  egg-plugin
Egg 24time
A Twitter-like news and social server for Egg. 微信小程序社区全栈解决方案
Stars: ✭ 493 (+300.81%)
Mutual labels:  egg-plugin
Egg Authz
egg-authz is an authorization middleware for Egg.js based on Casbin
Stars: ✭ 50 (-59.35%)
Mutual labels:  egg-plugin
egg-logger-sls
Logger transport for aliyun sls.
Stars: ✭ 14 (-88.62%)
Mutual labels:  egg-plugin
Egg Sofa Rpc
SOFARPC plugin for egg
Stars: ✭ 71 (-42.28%)
Mutual labels:  egg-plugin
egg-rest
Restful API plugin for egg
Stars: ✭ 106 (-13.82%)
Mutual labels:  egg-plugin
Egg View
Stars: ✭ 35 (-71.54%)
Mutual labels:  egg-plugin
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (-4.88%)
Mutual labels:  egg-plugin
Egg Schedule
Schedule plugin for egg
Stars: ✭ 76 (-38.21%)
Mutual labels:  egg-plugin
Egg View Ejs
egg view plugin for ejs.
Stars: ✭ 54 (-56.1%)
Mutual labels:  egg-plugin

egg-mongodb-example

a example of eggjs, mongodb, restful api and other stuff made it work...

Examples for egg

Usage

make sure you nodejs version >7.0 install mongodb start mongodb import data.json to mongodb

  1. create Collection: "web_admin" "web_news" "web_newsType" "IdGenerator"
  2. create Documents in data.json run npm to start server npm start
$ npm install
$ npm start

REST API Example

Follow the naming conventions of rails:

method url file path controller name
GET /api/{objects}[?per_page={per_page}&page={page}] app/controller/{objects}.js index()
GET /api/{objects}/:id app/controller/{objects}.js show()
POST /api/{objects} app/controller/{objects}.js create()
PUT /api/{objects}/:id app/controller/{objects}.js update()
DELETE /api/{objects}/:id[s] app/controller/{objects}.js destroy()

api/users GET List

{
"meta":{"total":3},
"data":[
{"_id":"58d8a899f5f2486f1f6d4236","uid":1,"name":"admin","pass":"123","status":1,"time":"1325472736"},
{"_id":"58db7828a14b14815447cf33","name":"sdf","pass":"123","status":1,"time":"1325472736","uid":3,"__v":0},
{"_id":"58db7d3bcee4d48df6f5bdfd","name":"sdddf","pass":"123","status":1,"time":"1325472736","uid":4,"__v":0}
]
}

api/users/1 GET Single Data

{
"meta":{"total":1},
"data":[
{"_id":"58d8a899f5f2486f1f6d4236","uid":1,"name":"admin","pass":"123","status":1,"time":"1325472736"}
]
}

api/users/2 PUT Update data with uid

{"name":"admin123","pass":"123","status":1,"time":"1325472736"}

api/users POST insert data

{"name":"admin123","pass":"123","status":1,"time":"1325472736"}

same with news and news_type for rest api data.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].