6 글 보임 - 1 에서 6 까지 (총 6 중에서)
-
글쓴이글
-
2023년 5월 3일 13:37 #80673
정중식참가자const user = await db.collection('user_card').findOne({ email }); console.log(user); 이렇게 하는거 맞을까요? 중복된 이메일인데 계속 null을 콘솔출력해줍니다. const user = await db.collection('user_card').find({ email }); console.log(user); 해주면 sessionPool: ServerSessionPool { client: [MongoClient], sessions: [List] }, hasEnded: false, clientOptions: [Object: null prototype] { hosts: [Array], credentials: [MongoCredentials], compressors: [Array], connectTimeoutMS: 30000, dbName: 'test', directConnection: false, driverInfo: {}, enableUtf8Validation: true, forceServerObjectId: false, heartbeatFrequencyMS: 10000, keepAlive: true, keepAliveInitialDelay: 120000, loadBalanced: false, localThresholdMS: 15, maxConnecting: 2, maxIdleTimeMS: 0, maxPoolSize: 100, minPoolSize: 0, minHeartbeatFrequencyMS: 500, monitorCommands: false, noDelay: true, pkFactory: [Object], raw: false, readPreference: [ReadPreference], retryReads: true, retryWrites: true, serverSelectionTimeoutMS: 30000, socketTimeoutMS: 0, srvMaxHosts: 0, srvServiceName: 'mongodb', waitQueueTimeoutMS: 0, zlibCompressionLevel: 0, useNewUrlParser: true, userSpecifiedAuthSource: false, userSpecifiedReplicaSet: false, srvHost: 'cluster0.ip8dsz4.mongodb.net', tls: true, mongoLoggerOptions: [Object], metadata: [Object], replicaSet: 'atlas-hdeny5-shard-0', [Symbol(@@mdb.enableMongoLogger)]: false }, explicit: false, supports: { causalConsistency: false }, clusterTime: undefined, operationTime: undefined, owner: [Circular *3], defaultTransactionOptions: {}, transaction: Transaction { state: 'NO_TRANSACTION', options: {}, _pinnedServer: undefined, _recoveryToken: undefined }, [Symbol(kCapture)]: false, [Symbol(snapshotEnabled)]: false, [Symbol(serverSession)]: null, [Symbol(txnNumberIncrement)]: 0 }, [Symbol(filter)]: {}, [Symbol(builtOptions)]: { raw: false, useBigInt64: false, promoteLongs: true, promoteValues: true, promoteBuffers: false, ignoreUndefined: false, bsonRegExp: false, serializeFunctions: false, fieldsAsRaw: {}, enableUtf8Validation: true, readPreference: ReadPreference { mode: 'primary', tags: undefined, hedge: undefined, maxStalenessSeconds: undefined, minWireVersion: undefined } } } 막 이런거 출력해줍니다. 제가 뭘 잘못한건지 모르겠어요..
2023년 5월 3일 17:22 #80734
정중식참가자센센세 계속 null이 나옵니다. signup.js 파일에 제가 쓴 코드입니다.
import { connectDB } from '@/util/database'; import bcrypt from 'bcrypt';
export default async function handler(req, res) { if (req.method === 'POST') { const { name, email, password } = req.body;
try { let db = (await connectDB).db('forum');
if (name === '' || email === '' || password === '') { return res.status(400).json('모든 칸을 입력해주세요'); }
const user = await db.collection('user_card').findOne({ email: email }); console.log(user); } catch (error) { console.log('error:', error); } } }
몽고디비에 저장되어있는건 다음 사진과 같아요
왜 null 이 나오는건지이유를 모르겠어요..
-
글쓴이글
6 글 보임 - 1 에서 6 까지 (총 6 중에서)
- 답변은 로그인 후 가능합니다.