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
Show 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
#!/bin/bash
npm
install
--save-exact
typeorm@0.2.45
npm
install
--save
\
npm
install
--save
\
class-validator
\
class-validator
\
class-transformer
\
class-transformer
\
@nestjs/swagger
\
@nestjs/swagger
\
swagger-ui-express
\
swagger-ui-express
\
typeorm
\
@nestjs/typeorm
\
@nestjs/typeorm
\
@nestjs/config
\
@nestjs/config
\
pg
\
pg
\
...
...
things/nest-typeorm/src/crud-base/crud-base.ts
View file @
77123080
import
{
ConsoleLogger
}
from
'
@nestjs/common
'
;
import
{
ConsoleLogger
}
from
'
@nestjs/common
'
;
import
{
ClassConstructor
}
from
'
class-transformer
'
;
import
{
ClassConstructor
}
from
'
class-transformer
'
;
import
{
import
{
DeepPartial
,
DeleteResult
,
DeleteResult
,
FindConditions
,
FindConditions
,
In
,
In
,
...
@@ -103,7 +104,7 @@ export class CrudBase<
...
@@ -103,7 +104,7 @@ export class CrudBase<
await
beforeCreate
(
repo
);
await
beforeCreate
(
repo
);
}
}
try
{
try
{
const
results
=
await
repo
.
save
(
ents
);
const
results
=
await
repo
.
save
(
ents
as
DeepPartial
<
T
>
[]
);
return
{
return
{
results
,
results
,
skipped
,
skipped
,
...
@@ -142,7 +143,7 @@ export class CrudBase<
...
@@ -142,7 +143,7 @@ export class CrudBase<
await
beforeCreate
(
repo
);
await
beforeCreate
(
repo
);
}
}
try
{
try
{
return
await
repo
.
save
(
ent
);
return
await
repo
.
save
(
ent
as
DeepPartial
<
T
>
);
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
error
(
this
.
error
(
`Failed to create entity
${
JSON
.
stringify
(
ent
)}
:
${
e
.
toString
()}
`
,
`Failed to create entity
${
JSON
.
stringify
(
ent
)}
:
${
e
.
toString
()}
`
,
...
@@ -335,7 +336,11 @@ export class CrudBase<
...
@@ -335,7 +336,11 @@ export class CrudBase<
);
);
await
Promise
.
all
(
remainingEnts
.
map
((
ent
)
=>
ent
.
prepareForSaving
()));
await
Promise
.
all
(
remainingEnts
.
map
((
ent
)
=>
ent
.
prepareForSaving
()));
const
{
data
}
=
await
this
.
batchCreate
(
remainingEnts
,
undefined
,
true
);
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
=
[
const
results
=
[
...
invalidResults
,
...
invalidResults
,
...
data
.
skipped
,
...
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