[英]MongooseError: Model.findOneAndUpdate() no longer accepts a callback
我在設置 mongoose 時遇到了問題。 我的代碼 錯誤: MongooseError: Model.findOneAndUpdate() 不再接受回調 Function.Model.findOneAndUpdate (C:\Users\Kous\Desktop\First-Full-Stack ...
[英]MongooseError: Model.findOneAndUpdate() no longer accepts a callback
我在設置 mongoose 時遇到了問題。 我的代碼 錯誤: MongooseError: Model.findOneAndUpdate() 不再接受回調 Function.Model.findOneAndUpdate (C:\Users\Kous\Desktop\First-Full-Stack ...
[英]MongooseError('Model.find() no longer accepts a callback');
這是我的代碼 這是錯誤 MongooseError('Model.find() 不再接受回調'); ...
[英]MongoError: Authentication failed with docker-compose
我正在嘗試構建此應用程序https://github.com/dwgebler/node-express-example 。 我想用它作為制作 Mongodb http 快遞服務器的模板。 我試圖在這個 repo 中構建 docker 撰寫文件,它看起來像這樣(稍作修改): 但是當我在與 dock ...
[英]Using Mongo ObjectId as an Index
我正在嘗試遍歷從Model.find()調用中檢索到的數組。 listId是new ObjectId(1234qwer1234qwer) ,錯誤是Type 'ObjectId' cannot be used as an index type. 處理這個問題的理想方法是什么? 不久之后,我可能會想在 ...
[英]MongoDB findOneAndDelete() will not delete the specified query-- I can't quite figure out why?
我正在嘗試編寫一個 Discord.JS 機器人,它使用 MongoDB 的 Model 和架構功能列出和刪除特定的頻道/線程。 我已經弄清楚了其他所有內容,實際的消息刪除、頻道刪除以及刪除 function 所需的所有其他內容,但出於某種原因提示 MongoDB 使用指定的 ID 刪除 Chat ...
[英]Just get back the value from a mongoose query
我試圖僅從 articlePrice 獲取價值。 而且還能得到屬性名。 我該如何解決? 最大值:{ articelPrice:560.5 } 最小值:{ articelPrice:230 } ...
[英]How do I migrate my data from one structure to another?
我有一個 MongoDB 和 3 個 collections。這是 3 個 collections,每個都有一個它包含的文檔示例: tag computer setting 如您所見,所有 3 個文檔都有一個category屬性,最后兩個文檔有一個tags屬性。 這個想法是您可以創建一個標簽並使用 ...
[英]mongoose transaction not working as expected
我有這段代碼,我在其中創建了一個 mongoose 交易。 但是它沒有像我預期的那樣工作。 正如您在此處看到的,我通過在交易完成之前拋出錯誤來測試交易。 但是,由於某種原因,帳戶總是被持久化而不是回滾事務。 為什么 ...
[英]Mongoose search query with regex not returning expected results with multiple conditions and population
后模態 用戶 Model Post model 引用了一個 User model 和一個 Group model。該方法使用 populate 方法用它們的相應數據填充這些引用。 查詢結果按創建時間降序排列,並作為響應發送給客戶端。 在 searchPost API 中,它在使用正則表達式查找時 ...
[英]How do I project id as something else with mongoose?
在我的Node.js微服務中,我使用Mongoose從我的 mongoDB 中獲取文檔。該文檔有很多屬性,但我只想投影其中的 3 個: 我想將“_id”投影為“id”,然后我想投影“名稱”和“描述”。 我試着這樣做: 但這是它返回的內容: ...
[英]mongoose , How to create a new item in an array if dose not exist and if it exists replace the item with the new entry
這是要更新或插入的 object,以防它不存在: 如果項目條目存在則替換為新條目,或者如果不存在則創建新條目。 非常感謝我不知道解決辦法 ...
[英]Using multiple mongodb databases and having dynamic calls based on url
我不確定是否應該創建多個數據庫。 但我認為多個數據庫會創建更好的數據。 所以我想創建一個應用程序,用戶可以在其中發布特定概念的鏈接,其他用戶可以對其投贊成票/反對票。 像 /react/useState /javascript/optionalChaning 所以用戶可以在這里發布 useState ...
[英]Nest Error - ERROR [ExceptionHandler] Nest can't resolve dependencies of the AuthService (?, JwtService)
我正在嘗試用於用戶身份驗證的 JWT 服務出現問題錯誤 [ExceptionHandler] Nest 無法解析 AuthService (?, JwtService) 的依賴項。 請確保索引 [0] 處的參數 UsersService 在 AuthModule 上下文中可用。 這是 auth.m ...
[英]Mongoose Querying on Array of Object or Virtual for array of Object
我有此頁面上定義的以下 Mongoose 架構 現在我想在 AuthorSchema 上創建一個虛擬的,以獲取具有該作者評論的 BlogPosts。 我嘗試創建一個虛擬 function 但沒有成功 ...
[英]How can I get the value of this array in MongoDB?
我怎樣才能得到這個數組的值 例子: 如何獲取MembersID:[0]:811664013313310720的值,在這種情況下為811664013313310720我需要它來檢查系統嘗試使用 findOne、Find 的方法 ...
[英]MongoDB Create Resolver - How to return the newly created document
我無法讓我的創建解析器返回新創建的文檔。 它為所有值返回 null。 這是代碼: 解析器 // SECTION SCHEDULE addSchedule: async ( parent, { _id, streetAddress, ...
[英]I want remove all user with pull all
我得到一個數組,其中我有 userid,我想從 purchasedUsers 中刪除所有用戶,但不獲取 object 屬性並且不刪除該 object,因為我無法訪問 purchasedUsers 數組中的 userId 屬性。 ...
[英]Using mongoose to write and retrieve data in nodejs backend
我更新了 MongoDb 和 Node.Js。 我應該檢查資產是否存在,然后(如果不存在)創建它。 這是資產模式 檢查資產是否存在 新建一個 不管怎樣,我查了一下,這兩種方法似乎都行不通。 我以為這是一個連接問題,但連接有效。 我使用 MongoDB Cloud,這是連接字符串 我錯過了什么? 兩 ...
[英]Find user dynamically
** 我想創建一個 function 接受任何數據,如 id、email 等,並根據傳遞給它的輸入找到用戶。 ** 前任: 我應該通過像(輸入,鍵)這樣的輸入來傳遞鍵嗎?? 所以我需要一個通用的 function 來動態查找用戶數據 ...
[英]How to find key with type objectId , ref to <some model>
我創建了一個 Notes model,其架構如下所示 為了向用戶展示他對特定任務/問題的筆記,我正在嘗試獲取筆記並向他展示,如果他做了一些更改並保存,可能會更新,問題在於這個模式我不知道如何寫 <model.findById >從我的筆記 model 中查找具有特定用戶和特定任務/問題的 ...