MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / fetchUsersListForMultipleValues

Function fetchUsersListForMultipleValues

models/users.js:950–977  ·  view source on GitHub ↗
(documentKey, valueList)

Source from the content-addressed store, hash-verified

948 }
949};
950
951/**
952 * Updates given list of users in batch
953 * @param usersData {Array} - Users list as an array.
954 * @param usersData.id {String} - User id which is the primary key of user model.
955 */
956const updateUsersInBatch = async (usersData) => {
957 try {
958 const bulkWriter = firestore.bulkWriter();
959 const userIds = [];
960
961 usersData.forEach((user) => {
962 const id = user.id;
963 delete user.id;
964 userIds.push(id);
965 bulkWriter.update(userModel.doc(id), { ...user, updated_at: Date.now() });
966 });
967
968 await bulkWriter.close();
969
970 userIds.forEach((id) => {
971 userCache.invalidateUser(id);
972 });
973 } catch (err) {
974 logger.error("Firebase batch operation failed!");
975 }
976};
977/**
978 * Fetch users based on document key and value.
979 * @param documentKey {String} - Model field path.
980 * @param value {String} - Field value.

Callers

nothing calls this directly

Calls 2

chunksFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected