source

마리아에서 메타 개체 데이터 숨기기nodejs 사용 시 DB

goodcode 2022. 9. 23. 00:14
반응형

마리아에서 메타 개체 데이터 숨기기nodejs 사용 시 DB

특정 쿼리의 결과를 로깅하고 있는데 정상적으로 동작하고 있는데, 메타데이터도 너무 많이 로깅되어 있는 것을 알 수 있습니다.이러한 메타데이터의 로그인을 무효로 하려면 어떻게 해야 합니까?

스크린샷

    const pool = mariadb.createPool({
        host: 'localhost',
        port: 3306,
        user: 'example',
        password: 'pass',
        waitForConnections: true,
        connectionLimit: 10
    });

    async function asyncFunction () {
        let conn;
        try {
            conn = await pool.getConnection();
            const queryResult = await conn.query('select * from test.sb__user where id=94');
            console.log(queryResult); // [ {val: 1}, meta: ... ]
        } catch (err) {
            throw err;
        } finally {
            if (conn) return conn.end();
        }
    }

Tomas B의 예를 따라 delete 키워드를 사용하여 메타를 삭제했지만 대신 Vanilla JS를 사용했습니다.

delete queryResult.meta;

lodash를 사용하면 queryResult 배열에서 메타 값이 제외됩니다.

_.difference(queryResult, ['meta'])

언급URL : https://stackoverflow.com/questions/66743758/hide-meta-object-data-in-mariadb-when-using-nodejs

반응형