Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nisum-scorecard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Venkaiah Naidu Singamchetty
nisum-scorecard
Commits
59edcf5b
Commit
59edcf5b
authored
Mar 13, 2024
by
Venkaiah Naidu Singamchetty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'reporteesapiadded'
parent
c94a2354
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
2 deletions
+55
-2
db.js
db.js
+14
-1
server.js
server.js
+30
-1
employee.js
src/schemas/employee.js
+10
-0
listServices
src/services/listServices
+1
-0
No files found.
db.js
View file @
59edcf5b
const
{
MongoClient
}
=
require
(
"mongodb"
)
let
dbConnection
module
.
exports
=
{
...
...
@@ -16,5 +17,17 @@ module.exports = {
return
cb
(
err
)
})
},
getDb
:
()
=>
dbConnection
getDb
:
()
=>
dbConnection
,
getModel
:
function
(
collectionName
){
let
dbConnection
=
dbConnection
();
try
{
return
dbConnection
.
model
(
collectionName
);
}
catch
(
error
)
{
// if (['PERM_AGING_LOG', 'PETITION_AGING_LOG'].indexOf(collectionName) > -1) {
// return dbConnection.model(collectionName, new this.mongoDb.Schema(models[collectionName], { optimisticConcurrency: true, versionKey: 'version' }))
// } else {
return
dbConnection
.
model
(
collectionName
,
new
this
.
mongoDb
.
Schema
(
models
[
collectionName
]))
// }
}
}
}
\ No newline at end of file
server.js
View file @
59edcf5b
...
...
@@ -29,4 +29,33 @@ app.get('/employee/:id', (req, res) => {
db
.
collection
(
'employees'
).
findOne
({
empId
:
Id
},{
projection
:{
_id
:
false
}})
.
then
(
result
=>
{
res
.
send
(
result
)
})
.
catch
(
error
=>
res
.
status
(
401
).
send
(
error
))
})
\ No newline at end of file
})
app
.
post
(
'/getreportees'
,
(
req
,
res
)
=>
{
let
reporteesArray
=
req
.
body
.
reportees
;
let
page
=
parseInt
(
req
.
query
.
page
)
||
1
;
let
limit
=
10
;
let
skip
=
(
page
-
1
)
*
limit
;
db
.
collection
(
'employees'
).
find
({
empId
:
{
$in
:
reporteesArray
}
},
{
projection
:
{
_id
:
false
}
})
.
skip
(
skip
)
.
limit
(
limit
)
.
toArray
()
.
then
(
result
=>
{
// Get the total count of data
db
.
collection
(
'employees'
).
countDocuments
({
empId
:
{
$in
:
reporteesArray
}
})
.
then
(
totalCount
=>
{
res
.
send
({
total
:
totalCount
,
currentPage
:
page
,
totalPages
:
Math
.
ceil
(
totalCount
/
limit
),
data
:
result
});
})
.
catch
(
error
=>
res
.
status
(
401
).
send
(
error
));
})
.
catch
(
error
=>
res
.
status
(
401
).
send
(
error
));
});
src/schemas/employee.js
0 → 100644
View file @
59edcf5b
import
{
Schema
}
from
"mongoose"
module
.
exports
=
{
employee
:{
empName
:
string
,
}
}
\ No newline at end of file
src/services/listServices
0 → 100644
View file @
59edcf5b
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment