mongoose

    0熱度

    1回答

    嘿我有一個問題,從我的數據庫中刪除嵌套數組,我想使用findOneAndUpdate和$pull。我的意思是從reply陣列中刪除項目。我嘗試通過_id找到評論項目並刪除此回覆項目,但這不起作用。請看下面我的代碼。 我的架構 var productSchema = new Schema({ description: [{ type: String, require: tru

    0熱度

    1回答

    我有以下模式: ip: String, port: Number, msgboard: [{ date: { type: Date, default: Date.now, expires: 120 }, msg: String }] 我想從創建120秒後自動刪除的消息。但上面的刪除是整個文件,而不僅僅是來自msgboar

    0熱度

    2回答

    我有如下嵌套的數據, { "_id" : ObjectId("5a30ee450889c5f0ebc21116"), "academicyear" : "2017-18", "fid" : "be02", "fname" : "ABC", "fdept" : "Comp", "degree" : "BE", "class" : "1", "sem" : "8", "dept" :

    0熱度

    1回答

    我正在編寫一個使用javascript,node,mongoDB和mongoose的小應用程序。我有兩個集合;用戶和組,其中每個組包含用戶 用戶的數組:{_ ID:{類型:字符串,必需:真}姓:{類型:字符串,必需:真},..} 組{ _id:{type:String,required:true},users:[{user:userSchema}]} 我正在使用Mocha和Superagent編寫

    0熱度

    1回答

    我一直在試圖找出已經通過MongoDB手動創建的索引(我已經通過mongobooster爲兩個字段創建了2d球形索引,並通過定義它來創建一個通過模式創建的索引)。現在,如果我在mongodbooster運行此查詢 db.collectionname.getIndexes(); 它結果我的3個文件與name.key和我已使用的索引。我想在貓鼬中執行相同的操作,我找不到相同的查詢。我想這 cons

    0熱度

    1回答

    我想查詢有和條件內或調理我的查詢 ChatGroup.find({$or:[ {$and : [{'members.user_id':user_id},{'members.is_removed':false} ]}, {'created_by':user_id} ]}]}) 但它沒有給我想要的結果

    1熱度

    2回答

    我有一個NodeJS服務器從兩個不同的API中獲取數據,然後我想在兩個JSON響應中合併結果。在這裏,我向您發送代碼: EventModal.eventSearch(eventReq, type, async function (eventRes) { EventModal.getBoostEvents(eventReq, type, async function (eventBoos

    0熱度

    2回答

    嗨我使用lambda函數檢查在本地運行的mongodb中的用戶名和密碼。 module.exports.handler = (event, context, callback) => { console.log('login'); const { username, password } = JSON.parse(event.body); console.log("u

    1熱度

    1回答

    我的架構 let citySchema = new mongoose.Schema({ ... }); let countrySchema = new mongoose.Schema({ regions : [{ cities : [ref: 'City'] }] }); 問題 - 如何插入現有城市到選擇的(通過_id)區。一個區域的_id是由貓

    0熱度

    1回答

    我遇到了node + express路由問題。我在IDE webstorms中默認提供了一個路由模式。我不確定我是否配置了一切,因爲我有這個錯誤。 我可以做一個GET /用戶和POST /用戶正確的郵遞員正確的結果。 路線/ users.js const express = require('express'); const router = express.Router(); const _