-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from shikshalokam/SB-29009
SB-29009 resolve for 4.7
- Loading branch information
Showing
4 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* name : programs.js | ||
* author : vishnu | ||
* created-date : 09-Mar-2022 | ||
* Description : programs related information. | ||
*/ | ||
module.exports = class Programs extends Abstract{ | ||
constructor() { | ||
super("programs"); | ||
} | ||
|
||
static get name() { | ||
return "programs"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* name : programs.js | ||
* author : Vishnu | ||
* created-date : 09-Mar-2022 | ||
* Description : program helper for DB interactions. | ||
*/ | ||
|
||
// Dependencies | ||
|
||
/** | ||
* Programs | ||
* @class | ||
*/ | ||
|
||
|
||
|
||
module.exports= class Programs{ | ||
/** | ||
* programs details. | ||
* @method | ||
* @name programsDocument | ||
* @param {Array} [filterData = "all"] - programs filter query. | ||
* @param {Array} [fieldsArray = "all"] - projected fields. | ||
* @param {Array} [skipFields = "none"] - field not to include | ||
* @returns {Array} program details. | ||
*/ | ||
|
||
static programsDocument( | ||
filterData = "all", | ||
fieldsArray = "all", | ||
skipFields = "none" | ||
) { | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
let queryObject = (filterData != "all") ? filterData : {}; | ||
let projection = {} | ||
|
||
if (fieldsArray != "all") { | ||
fieldsArray.forEach(field => { | ||
projection[field] = 1; | ||
}); | ||
} | ||
|
||
if( skipFields !== "none" ) { | ||
skipFields.forEach(field=>{ | ||
projection[field] = 0; | ||
}); | ||
} | ||
let programsDoc = | ||
await database.models.programs.find( | ||
queryObject, | ||
projection | ||
).lean(); | ||
|
||
return resolve(programsDoc); | ||
|
||
} catch (error) { | ||
return reject(error); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* name : programs-model.js. | ||
* author : Vishnu. | ||
* created-date : 09-Mar-2022. | ||
* Description : Schema for programs. | ||
*/ | ||
module.exports = { | ||
name: "programs", | ||
schema: { | ||
externalId: String, | ||
name: String, | ||
description: String, | ||
owner: String, | ||
createdBy: String, | ||
updatedBy: String, | ||
status: { | ||
type : String, | ||
index : true | ||
}, | ||
resourceType: [String], | ||
language: [String], | ||
keywords: [String], | ||
concepts: ["json"], | ||
imageCompression: {}, | ||
components: ["json"], | ||
components: ["json"], | ||
isAPrivateProgram : { | ||
default : false, | ||
type : Boolean | ||
}, | ||
scope : { | ||
entityType : String, | ||
entityTypeId : "ObjectId", | ||
entities : { | ||
type : Array, | ||
index : true | ||
}, | ||
roles : [{ | ||
_id : "ObjectId", | ||
code : { | ||
type : String, | ||
index : true | ||
} | ||
}] | ||
}, | ||
isDeleted: { | ||
default : false, | ||
type : Boolean, | ||
index : true | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters