Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
init-things
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
init-things
Commits
467a5732
Commit
467a5732
authored
Dec 17, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search
parent
b3fbeaf0
Pipeline
#7913
passed with stages
in 1 minute and 47 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
things/nest-typeorm/src/entities/bases/IdNameDescBase.entity.ts
.../nest-typeorm/src/entities/bases/IdNameDescBase.entity.ts
+2
-2
things/nest-typeorm/src/entities/bases/ManualNameDescBase.entity.ts
...t-typeorm/src/entities/bases/ManualNameDescBase.entity.ts
+2
-2
things/nest-typeorm/src/entities/utility/query.ts
things/nest-typeorm/src/entities/utility/query.ts
+16
-0
No files found.
things/nest-typeorm/src/entities/bases/IdNameDescBase.entity.ts
View file @
467a5732
...
...
@@ -2,7 +2,7 @@ import { IdNameBase } from './IdNameBase.entity';
import
{
IdNameDescWise
}
from
'
../interfaces/wises
'
;
import
{
EntityDescription
}
from
'
../decorators/extended
'
;
import
{
SelectQueryBuilder
}
from
'
typeorm
'
;
import
{
applyQueryProperty
Like
}
from
'
../utility/query
'
;
import
{
applyQueryProperty
Search
}
from
'
../utility/query
'
;
export
class
IdNameDescBase
extends
IdNameBase
implements
IdNameDescWise
{
@
EntityDescription
()
...
...
@@ -13,6 +13,6 @@ export class IdNameDescBase extends IdNameBase implements IdNameDescWise {
entityName
:
string
,
)
{
super
.
applyQuery
(
qb
,
entityName
);
applyQueryProperty
Like
(
this
,
qb
,
entityName
,
'
desc
'
);
applyQueryProperty
Search
(
this
,
qb
,
entityName
,
'
desc
'
);
}
}
things/nest-typeorm/src/entities/bases/ManualNameDescBase.entity.ts
View file @
467a5732
...
...
@@ -2,7 +2,7 @@ import { ManualNameBase } from './ManualNameBase.entity';
import
{
StringIdNameDescWise
}
from
'
../interfaces/wises
'
;
import
{
EntityDescription
}
from
'
../decorators/extended
'
;
import
{
SelectQueryBuilder
}
from
'
typeorm
'
;
import
{
applyQueryProperty
Like
}
from
'
../utility/query
'
;
import
{
applyQueryProperty
Search
}
from
'
../utility/query
'
;
export
class
ManualNameDescBase
extends
ManualNameBase
...
...
@@ -16,6 +16,6 @@ export class ManualNameDescBase
entityName
:
string
,
)
{
super
.
applyQuery
(
qb
,
entityName
);
applyQueryProperty
Like
(
this
,
qb
,
entityName
,
'
desc
'
);
applyQueryProperty
Search
(
this
,
qb
,
entityName
,
'
desc
'
);
}
}
things/nest-typeorm/src/entities/utility/query.ts
View file @
467a5732
...
...
@@ -29,3 +29,19 @@ export function applyQueryPropertyLike<T extends TimeBase>(
});
}
}
export
function
applyQueryPropertySearch
<
T
extends
TimeBase
>
(
obj
:
T
,
qb
:
SelectQueryBuilder
<
T
>
,
entityName
:
string
,
...
fields
:
(
keyof
T
)[]
)
{
for
(
const
field
of
fields
)
{
if
(
obj
[
field
]
==
null
)
{
continue
;
}
qb
.
andWhere
(
`
${
entityName
}
.
${
field
}
like ('%' || :
${
field
}
|| '%')`
,
{
[
field
]:
obj
[
field
],
});
}
}
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