목록nodejs (4)
taenyLog

https://www.mongodb.com/community/forums/t/option-usecreateindex-is-not-supported/123048 Option usecreateindex is not supported I am trying to connect mongoDB to my web app but it is saying that usercreateindex is not supported please help me with this This is the code from my index.js file const express = require('express'); const app = express(); const mongoose = require('mongoos www.mongodb.c..
findByIdAndDelete() 함수는 일치하는 문서를 찾아 제거하고 찾은 문서를 콜백에 전달 https://mongoosejs.com/docs/api/model.html Mongoose v7.3.1: Model Parameters: doc «Object» values for initial set [fields] «Object» optional object containing the fields that were selected in the query which returned this document. You do not need to set this parameter to ensure Mongoose handles your query projection mongoosejs.com

최신버전의 Node.js 사용하는 경우 JS파일에서 몽구스 모듈을 가져오고 강의 코드를 실행할때 .load index.js 명령 대신 node -i -e "$(< index.js)" 명령사용하자. 윈도우라면 깃배쉬 이용 .

Module.exports 사용 서로 다른 파일 간에 JavaScript코드를 공유하는 법 module.exports의 콘텐츠를 불러옴. 보통은 문자열을 불러오지않는다. 아래와 같은 방법을 씀 app.js에서 math.add를 콘솔에 찍으면 아래와 같은 방식으로 출력됨 아래와 같이 구조분해도 가능 위와 같은 코드로 처음부터 PI와 square만 참조하게 변형도 가능하다 module.exports전체를 대체하는 방법 직접 module.exports를 추가하는 방법 !! exports변수는 모듈의 파일 수준 범위 내에서 사용할 수 있으며 모듈이 평가되기 전에 module.exports의 값이 지정된다. 단축어 구문도 가능해서 module.exports.f = 를 exports.f = ...로 쓸 수 도 있다..