반응형

flutter 34

mongodb nodejs authentication failed 연결 오류

username, password를 사용해서 nodejs에서 mongoose로 db를 연결하기 위해서 아래와 같이 주소를 적고 연결했다. 'mongodb://usename:password@localhost:27017/DBname' 그런데 아래와 같은 authentication 에러가 났었다. 구글링을 해보니, authSource=admin을 넣어주면 된다고 했다. mongoose.connect('mongodb://usename:password@localhost:27017/DBname?authSource=admin', { useNewUrlParser: true, useUnifiedTopology: true, }).then(() => console.log('connected to db')).catch((er..

flutter 2022.09.12

nodejs excel file to json

nodejs에서 excelfile을 읽어와서 json으로 만들어주는 간편한 library가 있다. convert-excel-to-json이다. 설치를 위해서는 아래와 같이 입력한다. npm install convert-excel-to-json 코드 : const excelData = excelToJson({ sourceFile: filepath, sheets: [{ name: 'sheet_name', header: { rows: 1 }, columnToKey: { A: 'key', B: 'name', C: 'road', D: 'staff', } }] }); dataModel.insertMany(excelData.sheet_name, (err, data) => { if (err) { console.log(..

flutter 2022.09.05

mongodb All your data is a backed up. you must pay 0.04 BTC

어제 몽고디비 서버를 열어놓고 잤다가 오늘 오후에 디비를 들어가보니 데이터는 전부 사라져있고, readme db가 새로 만들어져있었다... 그리고 이런 글이 있었다.. All your data is a backed up. You must pay 0.04 BTC to 1BbompGz4bzKF57PNDxfkH5tpxWz2gA6Y 48 hours for recover it. After 48 hours expiration we will leaked and exposed all your data. In case of refusal to pay, we will contact the General Data Protection Regulation, GDPR and notify them that you store use..

flutter 2022.09.02

flutter에서 nodejs 서버로 이미지 업로드하기 - 서버부분

flutter에서 여러개의 이미지를 nodejs 서버로 업로드하기위해서는 multer를 사용해야한다! multer를 먼저 설정해줘야한다. destination을 이용해서 업로드할 이미지가 들어갈 폴더 이름을 바꿀 수 있다. filename을 이용해서 업로드할 파일 이름을 바꿀 수 있다. const upload = multer({ storage: multer.diskStorage({ destination: (req, file, cb) => { let keynum = req.params.keynum; let dir = 'uploads/' + keynum; if (!fs.existsSync(dir)) { fs.mkdirSync(dir) }; cb(null, dir); }, filename: (req, file..

flutter 2022.08.24

provider model for loop - flutter provider 빌드 순서

provider의 model 부분에서 함수를 만들었다. 그리고 그 함수 내에서 for loop를 사용하였는데, 다른 변수들은 바로바로 업데이트가 되는데, for loop 안에 들어있는 변수는 업데이트가 한발짝 느리게 된다.... 구글링을 해봤는데도 관련된 정보가 안나온다,,,,,(내가 못찾는 걸수도..!!) 여기서 한발짝 느리게라는 뜻이 이상할 수 있는데,,,, 다른 변수들 업데이트 될 때(이 변수들은 파라미터로 받은 값을 클래스에 저장해주는 역할만 한다) 같이 업데이트가 안되고, 나중에 된다는 거다... 이것도 flutter의 빌드 순서와 관련이 있는 것 같아 찾아보았다. flutter에서 stateless 위젯은 상태(state) 를 가지고 있지 않다. 그래서 부모위젯에서 받은 값이 변경되면 위젯이 ..

flutter 2022.07.30

A value of type 'Future<dynamic>' can't be returned from the method '' because it has a return type of 'Widget'

위젯에서 showDialog를 리턴해주니 다음과 같은 에러가 나왔다. A value of type 'Future' can't be returned from the method 'AddFriendDialog' because it has a return type of 'Widget' 인터넷에 검색해보니, showDialog가 async 함수이기 때문에 나는 에러라고 한다. (dialog가 닫힐때까지 - 결과가 나올때까지 기다린다는 뜻) 그래서 showDialog의 closing bracket에 .then을 붙여주면 된다. (.then의 의미 : 값을 받을때 ) Future AddFriendDialog(context) async { return showDialog( context: context, builde..

flutter 2022.07.28

mongoose populate

지난 포스팅에서 subdocument를 만들었다. user가 triplist를 가지고있고, triplist안에는 trip을 subdocument로 가지고 있다. 이때, trip 내용을 가져오고 싶을 때 사용하는 것이 populate 이다. router.get("/trips/:userid", (req, res) => { userModel.find({ _id: req.params.userid }, (err, user) => { user[0].populate({ path: 'triplist', populate: { path: 'trip' } }).then(trip => { res.json(trip); }); }); }) 코드 설명을 하자면, 서버에서 userid를 받았다. 그리고 userModel DB에서 u..

flutter 2022.07.22
반응형