@jayant-singh/medicine-model 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jayant-singh/medicine-model",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Project for medicine project model along with core utilities",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "jayant.singh",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@types/node": "^25.6.0",
|
|
13
|
+
"mongodb": "^7.1.1",
|
|
14
|
+
"mongoose": "^9.4.1",
|
|
15
|
+
"mongoose-sequence": "^6.0.1"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndianStardardTimeFormat is a method to convert any time format to Indian Standard Time <br>
|
|
3
|
+
* extendedTime param by default takes the value 0, it accepts milli seconds and returns future date
|
|
4
|
+
*/
|
|
5
|
+
const IndianStandardTimeFormat = (extendedTime=0)=>{
|
|
6
|
+
let nowUTC = new Date();
|
|
7
|
+
// console.log('nowUTC',nowUTC);
|
|
8
|
+
nowUTC = new Date(nowUTC.getTime()+extendedTime);
|
|
9
|
+
// console.log('Extender UTC',nowUTC);
|
|
10
|
+
let nowIST;
|
|
11
|
+
if(nowUTC.toString().includes('India Standard Time')){
|
|
12
|
+
nowIST = nowUTC;
|
|
13
|
+
}else{
|
|
14
|
+
nowIST = new Date(nowUTC.getTime()+(5.5*60*60*1000));
|
|
15
|
+
}
|
|
16
|
+
// console.log('Final IST ',nowIST);
|
|
17
|
+
return nowIST;
|
|
18
|
+
};
|
|
19
|
+
module.exports = IndianStandardTimeFormat;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const AutoIncrement = require('mongoose-sequence')(mongoose);
|
|
3
|
+
const Schema = mongoose.Schema;
|
|
4
|
+
const {addAuditColumns} = require('./audit');
|
|
5
|
+
const TableName = require('@utils/DB/TableNames');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} LuLanguageType
|
|
9
|
+
* @property {number} pkLuLanguageId
|
|
10
|
+
* @property {string} commonLanguageName
|
|
11
|
+
* @property {string} translationSupportedLanguageName
|
|
12
|
+
* @property {string} languageCode
|
|
13
|
+
* @property {Date} createdAt
|
|
14
|
+
* @property {Date} updatedAt
|
|
15
|
+
*/
|
|
16
|
+
const lu_language = new Schema(
|
|
17
|
+
/** @type {import('mongoose').SchemaDefinition} */
|
|
18
|
+
({
|
|
19
|
+
commonLanguageName:{
|
|
20
|
+
type:String,
|
|
21
|
+
required:true,
|
|
22
|
+
unique:true
|
|
23
|
+
},
|
|
24
|
+
translationSupportedLanguageName:{
|
|
25
|
+
type:String,
|
|
26
|
+
required:true,
|
|
27
|
+
unique:true
|
|
28
|
+
},
|
|
29
|
+
languageCode:{
|
|
30
|
+
type:String,
|
|
31
|
+
required:true,
|
|
32
|
+
unique:true,
|
|
33
|
+
},
|
|
34
|
+
...addAuditColumns()
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
lu_language.plugin(AutoIncrement,{inc_field:'pkLuLanguageId'});
|
|
38
|
+
/** @type {import('mongoose').Model<LuLanguageDoc>} */
|
|
39
|
+
const LuLanguage = mongoose.model(TableName.lu_language,lu_language,TableName.lu_language);
|
|
40
|
+
module.exports = LuLanguage;
|
|
41
|
+
exports.deleteLanguagebyPkId=(pkId)=>{
|
|
42
|
+
LuLanguage.findOne({})
|
|
43
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const {addAuditColumns} = require('@models/audit');
|
|
2
|
+
const mongoose = require('mongoose');
|
|
3
|
+
const AutoIncrement = require('mongoose-sequence')(mongoose);
|
|
4
|
+
const Schema = mongoose.Schema;
|
|
5
|
+
const TableName = require('@utils/DB/TableNames');
|
|
6
|
+
const LuMesages = new Schema(
|
|
7
|
+
/** @type {import('mongoose').SchemaDefinition} */
|
|
8
|
+
({
|
|
9
|
+
messageKey:{
|
|
10
|
+
type:String,
|
|
11
|
+
required : [true,'messageKey is a required field'],
|
|
12
|
+
unique : [true,'messageKey is a unique field'],
|
|
13
|
+
uppercase : true,
|
|
14
|
+
},
|
|
15
|
+
englishText:{
|
|
16
|
+
type:String,
|
|
17
|
+
required : [true,'englishText is a required field'],
|
|
18
|
+
unique : [true,'englishText is a unique field'],
|
|
19
|
+
validate:{
|
|
20
|
+
validator:function(val){
|
|
21
|
+
return /^[a-zA-Z]+([ ][a-zA-Z]+)*$/.test(String(val).trim())
|
|
22
|
+
},
|
|
23
|
+
message : prop => `Invalid English Translation : ${prop.value}`
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
fkLanguageId:{
|
|
27
|
+
type : Schema.Types.ObjectId,
|
|
28
|
+
required : true,
|
|
29
|
+
},
|
|
30
|
+
autoTranslatedText : {
|
|
31
|
+
type:String,
|
|
32
|
+
required : false,
|
|
33
|
+
unique : [true,'autoTranslatedText is a unique field'],
|
|
34
|
+
},
|
|
35
|
+
status:{
|
|
36
|
+
type:String,
|
|
37
|
+
required : true,
|
|
38
|
+
enum:['New','In Progress','Success','Failed'],
|
|
39
|
+
default : 'New',
|
|
40
|
+
index : true,
|
|
41
|
+
},
|
|
42
|
+
manuallyTranslatedText:{
|
|
43
|
+
type:String,
|
|
44
|
+
required : false,
|
|
45
|
+
unique : [true,'manullyTranslatedText is a unique field'],
|
|
46
|
+
},
|
|
47
|
+
isMarkedForReExecution:{
|
|
48
|
+
type:Boolean,
|
|
49
|
+
required:false,
|
|
50
|
+
default : false,
|
|
51
|
+
},
|
|
52
|
+
reExecutionStatus:{
|
|
53
|
+
type:String,
|
|
54
|
+
required:false,
|
|
55
|
+
enum:['New','In Progress','Success','Failed'],
|
|
56
|
+
default : null,
|
|
57
|
+
index : true,
|
|
58
|
+
},
|
|
59
|
+
errorMessage:{
|
|
60
|
+
type:String,
|
|
61
|
+
required:false,
|
|
62
|
+
default:null
|
|
63
|
+
},
|
|
64
|
+
...addAuditColumns(),
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
LuMesages.plugin(AutoIncrement,{inc_field:'pkLuMessagesId'});
|
|
68
|
+
module.exports = mongoose.model(TableName.lu_messages,LuMesages,TableName.lu_messages);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const IndianStandardTimeFormat = require('@utils/TimeFormat');
|
|
2
|
+
const auditSchema = {
|
|
3
|
+
createUser : {
|
|
4
|
+
type : String,
|
|
5
|
+
required : true,
|
|
6
|
+
immutable : true,
|
|
7
|
+
},
|
|
8
|
+
createTime : {
|
|
9
|
+
type : Date,
|
|
10
|
+
required : true,
|
|
11
|
+
set : ()=> IndianStandardTimeFormat(0),
|
|
12
|
+
},
|
|
13
|
+
updateUser:{
|
|
14
|
+
type:String,
|
|
15
|
+
required : false,
|
|
16
|
+
},
|
|
17
|
+
updateTime:{
|
|
18
|
+
type : Date,
|
|
19
|
+
required : false,
|
|
20
|
+
},
|
|
21
|
+
isDeleted:{
|
|
22
|
+
type:Boolean,
|
|
23
|
+
required:true,
|
|
24
|
+
default :false,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.addAuditColumns=()=>{
|
|
29
|
+
return auditSchema;
|
|
30
|
+
}
|