Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

NOT FOUND

Mongoose find method is not working 본문

db

Mongoose find method is not working

신토불이 2023. 8. 29. 17:11
async findByCategoryCode(category: string, page: number, size: number) {
    console.log(category);
    const test = await this.model.find({categoryCode: "C-1"}).explain().exec();
    console.log(test);
    const test2 = await this.model.aggregate([
        {
            $match: {
                categoryCode: "C-2"
            }
        }
    ]).exec();
    console.log(test2);
    return this.model.find({'$categoryCode': "C-1"}).skip((page - 1) * size).limit(size).exec();
}

 

const test = await this.model.find({categoryCode: "C-1"}).explain().exec();

 

const test2 = await this.model.aggregate([
    {
        $match: {
            categoryCode: "C-2"
        }
    }
]).exec();

 

explain으ㄹ 사용해서 쿼리를 봤더니 filter에 아무것도 들어있지 않았다.

데이터베이스에 code값이 없었다.

'db' 카테고리의 다른 글

csv 파일 maria db에 업로드 시 \n이 제대로 출력이 안됨  (0) 2024.01.29