Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-05-06 03:17:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fb3ca07f9db34da9a76cdb5bbeb34b54d0663ef0
fb3ca07f
1 parent
3538eec4
db. update medicine data
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
server/index.js
server/src/models/medicine.js
server/index.js
View file @
fb3ca07
...
...
@@ -4,6 +4,7 @@ const bodyparser = require('koa-bodyparser');
const
Mongoose
=
require
(
'mongoose'
);
const
api
=
require
(
'./src/api'
);
const
updateMedicineInfo
=
require
(
'./src/lib/UpdatingMedicineInfo'
);
require
(
'dotenv'
).
config
();
const
{
SERVER_PORT
,
MONGO_URL
}
=
process
.
env
;
...
...
@@ -12,6 +13,8 @@ const app = new Koa();
const
router
=
new
Router
();
updateMedicineInfo
.
updateMedicineInfo
();
Mongoose
.
connect
(
MONGO_URL
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
...
...
server/src/models/medicine.js
View file @
fb3ca07
const
mongoose
=
require
(
'mongoose'
);
const
Schema
=
mongoose
.
Schema
;
const
MedicineSchema
=
new
Schema
({
medicineId
:
{
type
:
Number
,
required
:
true
,
unique
:
true
},
name
:
{
type
:
String
,
required
:
true
},
company
:
String
,
target
:
{
type
:
String
,
required
:
true
},
dosage
:
{
type
:
String
,
required
:
true
},
warn
:
{
type
:
String
,
required
:
true
},
antiEffect
:
String
})
MedicineSchema
.
statics
.
findByName
=
async
function
(
name
)
{
const
all
=
await
this
.
find
().
exec
();
const
result
=
all
.
filter
(
item
=>
{
return
item
.
name
.
includes
(
name
)
});
return
result
;
};
MedicineSchema
.
statics
.
findByCompany
=
async
function
(
company
)
{
const
all
=
await
this
.
find
().
exec
();
const
result
=
all
.
filter
(
item
=>
{
return
item
.
company
.
includes
(
company
)
});
return
result
;
};
MedicineSchema
.
statics
.
findByTarget
=
async
function
(
target
)
{
const
all
=
await
this
.
find
().
exec
();
const
result
=
all
.
filter
(
item
=>
{
return
item
.
target
.
includes
(
target
)
});
return
result
;
};
MedicineSchema
.
statics
.
findById
=
async
function
(
medicineId
)
{
return
this
.
findOne
({
medicineId
})
}
module
.
exports
=
mongoose
.
model
(
'Medicine'
,
MedicineSchema
);
\ No newline at end of file
...
...
Please
register
or
login
to post a comment