heimi-block / egg-restfulapi Goto Github PK
View Code? Open in Web Editor NEW🏅 基于Egg.js 2.0 & {mongoose,jwt}RESTful API 模板,用于快速集成开发RESTful前后端分离的服务端。
🏅 基于Egg.js 2.0 & {mongoose,jwt}RESTful API 模板,用于快速集成开发RESTful前后端分离的服务端。
由于 mongoose populate virtuals 的结果默认不保存在 _doc 字段,而是存储在一个特殊的 $$populatedVirtuals 字段中,所以在整理数据源的部分,如果只打包 _doc 的数据,则会丢失 populate virtuals 的数据。
遇到这个问题的朋友可以参考我的方法进行修改。或者有其他的方法能包含进 populate virtuals 的数据,也请不吝分享。
// 整理数据源 -> Ant Design Pro
let data = res.map((e,i) => {
// const jsonObject = Object.assign({}, e._doc)
// change to
const _doc = Object.assign(e._doc, e['$$populatedVirtuals'])
const jsonObject = Object.assign({}, _doc)
jsonObject.key = i
jsonObject.createdAt = this.ctx.helper.formatTime(e.createdAt)
return jsonObject
})
controler里的app.jwt是什么?没看到egg-jwt相关逻辑
用户可以模拟请求,删除其他人的资源怎么办?
你好,请问这里的登出怎么处理?
async create(payload) {
const { ctx, service } = this
const role = await service.role.fetch(payload.role)
if (!role) {
ctx.throw(404, 'role is not found')
}
payload.password = await this.ctx.genHash(payload.password)
return ctx.model.User.create(payload)
}
没有service.role.fetch 方法
应该是 show 方法
token那里生成?存储在哪?我在您的代码中一点都没看到啊
如下:
/uploads/avatar/5e79c57e1f32e032a8299840.png
请问怎么才能显示出来?
I recently used eggjs, helped me with some examples of decentralization, and user rights testing. thank you
如何把权限和角色加进去?
看到在service中直接调用model的一些方法:
但是在model中并没有声明,想了解下这是自带的还是
想问下,mongodb里面的数据如何初始化
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.