Skip to content

Commit

Permalink
Merge pull request #121 from shikshalokam/ED-599-Integration
Browse files Browse the repository at this point in the history
Programs description changes.
  • Loading branch information
aks30 authored May 16, 2023
2 parents 2afc34a + 9b7cc60 commit 3fe14d3
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 77 deletions.
96 changes: 48 additions & 48 deletions controllers/v1/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,60 +135,60 @@
// })
// }

// *
// * @api {post} /kendra/api/v1/admin/dbUpdate/:collectionName
// * Update the data in collection
// * @apiVersion 1.0.0
// * @apiGroup Admin
// * @apiSampleRequest /kendra/api/v1/admin/dbUpdate/projects
// * @param {json} Request-Body:
// * {
// "findQuery": {
// "_id": { "$in" : ["601921e86ffa9c5e9d0b53e7"] }
// },
// "mongoIdKeys" : ["_id"],
// "updateQuery" : {
// "$set" : { "status": "started"}
// }
// }
// * @apiParamExample {json} Response:
// * {
// "message": "Data Updated successfully",
// "status": 200
// * }
// * @apiUse successBody
// * @apiUse errorBody
/**
* @api {post} /kendra/api/v1/admin/dbUpdate/:collectionName
* Update the data in collection
* @apiVersion 1.0.0
* @apiGroup Admin
* @apiSampleRequest /kendra/api/v1/admin/dbUpdate/projects
* @param {json} Request-Body:
* {
"findQuery": {
"_id": { "$in" : ["601921e86ffa9c5e9d0b53e7"] }
},
"mongoIdKeys" : ["_id"],
"updateQuery" : {
"$set" : { "status": "started"}
}
}
* @apiParamExample {json} Response:
* {
"message": "Data Updated successfully",
"status": 200
* }
* @apiUse successBody
* @apiUse errorBody
// /**
// * Update the data in collection
// * @method
// * @name dbUpdate
// * @param {String} _id - MongoDB Collection Name
// * @param {Object} req - Req Body
// * @returns {JSON} list of data.
// */
/**
* Update the data in collection
* @method
* @name dbUpdate
* @param {String} _id - MongoDB Collection Name
* @param {Object} req - Req Body
* @returns {JSON} list of data.
*/

// async dbUpdate(req) {
// return new Promise(async (resolve, reject) => {
// try {
async dbUpdate(req) {
return new Promise(async (resolve, reject) => {
try {

// let result = await adminHelper.dbUpdate(
// req.params._id,
// req.body
// );
let result = await adminHelper.dbUpdate(
req.params._id,
req.body
);

// return resolve(result);
return resolve(result);

// } catch (error) {
// return reject({
// status: error.status || httpStatusCode.internal_server_error.status,
// message: error.message || httpStatusCode.internal_server_error.message,
// errorObject: error
// })
// }
// })
// }
} catch (error) {
return reject({
status: error.status || httpStatusCode.internal_server_error.status,
message: error.message || httpStatusCode.internal_server_error.message,
errorObject: error
})
}
})
}

/**
* @api {post} /kendra/api/v1/admin/dbCreate/:collectionName
Expand Down
3 changes: 1 addition & 2 deletions generics/constants/api-responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ module.exports = {
"ERROR_CREATING_PROGRAM" : "Error creating program",
"PROGRAM_NOT_FOUND" : "Program not found" ,
"PROGRAM_EXIST" : "Program exist",
"PROGRAM_DESCRIPTION" : "Program description",
"USER_TARGETED_PROGRAMS_FETCHED" : "Users programs fetched successfully",
"USER_TARGETED_SOLUTIONS_FETCHED" : "Users solutions fetched successfully",
"ROLE_REQUIRED_IN_SCOPE" : "Required role in scope",
Expand All @@ -148,7 +147,7 @@ module.exports = {
"TARGETED_SOLUTIONS_FETCHED": "Successfully targeted solutions fetched",
"NO_ENTITY_FOUND_IN_LOCATION": "Entity not found in location",
"TARGETED_PROGRAMS_FETCHED": "Targeted programs fetched successfully",
"PROGRAM_DESCRIPTION": "View and participate in educational programs active in your location and designed for your role",
"PROGRAM_DESCRIPTION": "View and participate in educational programs active in your location and designed for the role you selected",
"ENTITIES_NOT_EXIST_IN_LOCATION" : "Entities does not belongs in the location",
"ROLES_ADDED_IN_PROGRAM" : "Successfully added roles in program scope",
"ENTITIES_ADDED_IN_PROGRAM" : "Successfully added entities in program scope",
Expand Down
54 changes: 27 additions & 27 deletions module/admin/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,38 +176,38 @@ module.exports = class adminHelper {
// })
// }

// /**
// * Update the data in any model
// * @method
// * @name dbUpdate
// * @param {Object} reqBody - request body
// * @returns {Object} - collection details.
// */
/**
* Update the data in any model
* @method
* @name dbUpdate
* @param {Object} reqBody - request body
* @returns {Object} - collection details.
*/

// static dbUpdate( collection, reqBody ) {
// return new Promise(async (resolve, reject) => {
// try {
static dbUpdate( collection, reqBody ) {
return new Promise(async (resolve, reject) => {
try {

// if ( reqBody.mongoIdKeys ) {
// reqBody.query = await this.convertStringToObjectIdInQuery(reqBody.findQuery, reqBody.mongoIdKeys);
// }
if ( reqBody.mongoIdKeys ) {
reqBody.query = await this.convertStringToObjectIdInQuery(reqBody.findQuery, reqBody.mongoIdKeys);
}

// let updateData = await database.getCollection(collection).updateMany(reqBody.findQuery, reqBody.updateQuery);
let updateData = await database.getCollection(collection).updateMany(reqBody.findQuery, reqBody.updateQuery);

// return resolve({
// message : constants.apiResponses.DATA_UPDATED_SUCCESSFULLY,
// success : true
// });
return resolve({
message : constants.apiResponses.DATA_UPDATED_SUCCESSFULLY,
success : true
});

// } catch (error) {
// return resolve({
// success: false,
// message: error.message,
// data: false
// });
// }
// })
// }
} catch (error) {
return resolve({
success: false,
message: error.message,
data: false
});
}
})
}

/**
* Create a new mongodb record
Expand Down

0 comments on commit 3fe14d3

Please sign in to comment.