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
77123080
Commit
77123080
authored
Apr 01, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renew
parent
b8168cdb
Pipeline
#11419
passed with stages
in 1 minute and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
things/nest-typeorm/install-npm.sh
things/nest-typeorm/install-npm.sh
+2
-1
things/nest-typeorm/src/crud-base/crud-base.ts
things/nest-typeorm/src/crud-base/crud-base.ts
+8
-3
things/nest-typeorm/src/dto/import-entry.dto.ts
things/nest-typeorm/src/dto/import-entry.dto.ts
+11
-0
No files found.
things/nest-typeorm/install-npm.sh
View file @
77123080
#!/bin/bash
npm
install
--save-exact
typeorm@0.2.45
npm
install
--save
\
class-validator
\
class-transformer
\
@nestjs/swagger
\
swagger-ui-express
\
typeorm
\
@nestjs/typeorm
\
@nestjs/config
\
pg
\
...
...
things/nest-typeorm/src/crud-base/crud-base.ts
View file @
77123080
import
{
ConsoleLogger
}
from
'
@nestjs/common
'
;
import
{
ClassConstructor
}
from
'
class-transformer
'
;
import
{
DeepPartial
,
DeleteResult
,
FindConditions
,
In
,
...
...
@@ -103,7 +104,7 @@ export class CrudBase<
await
beforeCreate
(
repo
);
}
try
{
const
results
=
await
repo
.
save
(
ents
);
const
results
=
await
repo
.
save
(
ents
as
DeepPartial
<
T
>
[]
);
return
{
results
,
skipped
,
...
...
@@ -142,7 +143,7 @@ export class CrudBase<
await
beforeCreate
(
repo
);
}
try
{
return
await
repo
.
save
(
ent
);
return
await
repo
.
save
(
ent
as
DeepPartial
<
T
>
);
}
catch
(
e
)
{
this
.
error
(
`Failed to create entity
${
JSON
.
stringify
(
ent
)}
:
${
e
.
toString
()}
`
,
...
...
@@ -335,7 +336,11 @@ export class CrudBase<
);
await
Promise
.
all
(
remainingEnts
.
map
((
ent
)
=>
ent
.
prepareForSaving
()));
const
{
data
}
=
await
this
.
batchCreate
(
remainingEnts
,
undefined
,
true
);
data
.
results
.
forEach
((
e
)
=>
e
.
afterSaving
());
data
.
results
.
forEach
((
e
)
=>
{
if
(
e
.
afterSaving
)
{
e
.
afterSaving
();
}
});
const
results
=
[
...
invalidResults
,
...
data
.
skipped
,
...
...
things/nest-typeorm/src/dto/import-entry.dto.ts
0 → 100644
View file @
77123080
import
{
ApiProperty
}
from
'
@nestjs/swagger
'
;
export
class
ImportEntryBaseDto
{
@
ApiProperty
({
description
:
'
导入结果
'
})
result
:
string
;
}
export
interface
ImportEntry
<
T
>
{
entry
:
T
;
result
:
string
;
}
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