Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
meanspec-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MeanSpec (SCE338 2024-2 Group 1)
meanspec-backend
Commits
7bdca999
Commit
7bdca999
authored
7 months ago
by
Lee WooChang
Browse files
Options
Downloads
Patches
Plain Diff
feat: partRepository 추가
parent
193efb2f
No related branches found
No related tags found
1 merge request
!10
Parts 추가
Pipeline
#10562
passed
7 months ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/repositories/partRepository.js
+39
-0
39 additions, 0 deletions
src/repositories/partRepository.js
with
39 additions
and
0 deletions
src/repositories/partRepository.js
+
39
−
0
View file @
7bdca999
...
@@ -17,6 +17,45 @@ const PartRepository = {
...
@@ -17,6 +17,45 @@ const PartRepository = {
const
[
info
]
=
resp
.
rows
;
const
[
info
]
=
resp
.
rows
;
return
info
;
return
info
;
},
},
async
getColumnsByType
(
type
)
{
const
resp
=
await
pool
.
query
(
`
SELECT column_name
FROM information_schema.columns
WHERE table_name = $1
ORDER BY ordinal_position;
`
,
[
`part_info_
${
type
}
`
.
toLowerCase
()]
);
return
resp
.
rows
.
map
((
row
)
=>
row
.
column_name
);
},
async
getFilterDataByTypeAndColumn
(
type
,
column
)
{
const
query
=
`
SELECT DISTINCT
${
column
}
FROM part_info_
${
type
}
WHERE
${
column
}
IS NOT NULL
ORDER BY
${
column
}
`
;
const
resp
=
await
pool
.
query
(
query
);
return
resp
.
rows
.
map
((
row
)
=>
row
[
column
]);
},
async
getPartsByFilters
(
partType
,
whereClauses
,
queryValues
)
{
const
query
=
`
SELECT
parts.id AS partId,
parts.name,
parts.image_url
FROM part_info_
${
partType
.
toLowerCase
()}
INNER JOIN parts
ON part_info_
${
partType
.
toLowerCase
()}
.part_id = parts.id
${
whereClauses
?
`WHERE
${
whereClauses
}
`
:
''
}
LIMIT 20;
`
;
const
result
=
await
pool
.
query
(
query
,
queryValues
);
return
result
.
rows
;
},
};
};
export
default
PartRepository
;
export
default
PartRepository
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment