文章詳情頁
javascript - mongoose save不起作用也沒有反應~~
瀏覽:166日期:2024-03-27 08:53:29
問題描述
const register = async (ctx, next) => { console.log(123) const opts = ctx.request.body const newUser = await user.save(opts) console.log(newUser)}
123能打印,new User也能打印, 然后到 save 的方法這里 就停住了 什么反應都沒有??
這是怎么回事??
看了 issues https://github.com/Automattic... 還是沒有解決??怎么辦??
問題解答
回答1:阿西吧 就是mongodb連接的原因、把代碼直接放在最上邊就可以了
const mongoose = require(’mongoose’)mongoose.Promise = require(’bluebird’)mongoose.connect(’mongodb://localhost/blog’)
標簽:
JavaScript
相關文章:
1. html5 - 有可以一次性把所有 css外部樣式轉為html標簽內style=" "的方法嗎?2. javascript - 求解答:實例對象調用constructor,此時constructor內的this的指向?3. javascript - 如何將一個div始終固定在某個位置;無論屏幕和分辨率怎么變化;div位置始終不變4. javascript - 這不是對象字面量函數嗎?為什么要new初始化?5. javascript - vscode alt+shift+f 格式化js代碼,通不過eslint的代碼風格檢查怎么辦。。。6. html - vue項目中用到了elementUI問題7. javascript - 有什么比較好的網頁版shell前端組件?8. javascript - iframe 為什么加載網頁的時候滾動條這樣顯示?9. javascript - [js]為什么畫布里不出現圖片呢?在線等10. javascript - 原生canvas中如何獲取到觸摸事件的canvas內坐標?
排行榜
