Skip to content

Commit

Permalink
Update log message
Browse files Browse the repository at this point in the history
  • Loading branch information
Gutierrez, Andres committed Apr 30, 2021
1 parent 73fefce commit bb1606a
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions src/resolvers/apis/dal.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { dbc, ObjectId, withErrorHandler, logger } from "../../infrastructure";

const searchAllApis = async (limit = null, next = 0) => {
logger.debug(`Calling to db -> get all responses`);
if (limit !== null) {
return await dbc.apis.find({})
.skip(next)
.limit(limit)
.toArray();
}
return await dbc.apis.find({}).toArray();
};

const searchAnApi = async (apiIds) => {
logger.debug(`Calling to db -> Get api: ${apiIds}`);
if (!Array.isArray(apiIds)) {
apiIds = [apiIds];
}

const listObjectIds = apiIds.map((id) => ObjectId(id));
return await dbc.apis.find({ _id: { $in: listObjectIds } }).toArray();
};

const countApis = async () => await dbc.apis.countDocuments({});


export default {
searchAllApis: withErrorHandler(searchAllApis),
searchAnApi: withErrorHandler(searchAnApi),
countApis: withErrorHandler(countApis),
};
import { dbc, ObjectId, withErrorHandler, logger } from "../../infrastructure";

const searchAllApis = async (limit = null, next = 0) => {
logger.debug(`Calling to db -> get all apis`);
if (limit !== null) {
return await dbc.apis.find({})
.skip(next)
.limit(limit)
.toArray();
}
return await dbc.apis.find({}).toArray();
};

const searchAnApi = async (apiIds) => {
logger.debug(`Calling to db -> Get api: ${apiIds}`);
if (!Array.isArray(apiIds)) {
apiIds = [apiIds];
}

const listObjectIds = apiIds.map((id) => ObjectId(id));
return await dbc.apis.find({ _id: { $in: listObjectIds } }).toArray();
};

const countApis = async () => await dbc.apis.countDocuments({});


export default {
searchAllApis: withErrorHandler(searchAllApis),
searchAnApi: withErrorHandler(searchAnApi),
countApis: withErrorHandler(countApis),
};

0 comments on commit bb1606a

Please sign in to comment.