Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
Resin
Server
Commits
f0b382ce
Commit
f0b382ce
authored
3 years ago
by
Hugo SUBTIL
Browse files
Options
Downloads
Patches
Plain Diff
feat: migrate null values to 0 for equipments
parent
79f55d01
No related branches found
No related tags found
2 merge requests
!104
Dev
,
!98
feat: migrate null values to 0 for equipments
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/migrations/scripts/1640095148120-remove-equipments-null-values.ts
+56
-0
56 additions, 0 deletions
...ns/scripts/1640095148120-remove-equipments-null-values.ts
src/structures/services/aptic-structures.service.ts
+5
-5
5 additions, 5 deletions
src/structures/services/aptic-structures.service.ts
with
61 additions
and
5 deletions
src/migrations/scripts/1640095148120-remove-equipments-null-values.ts
0 → 100644
+
56
−
0
View file @
f0b382ce
import
{
Db
}
from
'
mongodb
'
;
import
{
getDb
}
from
'
../migrations-utils/db
'
;
export
const
up
=
async
()
=>
{
const
db
:
Db
=
await
getDb
();
const
cursor
=
db
.
collection
(
'
structures
'
).
find
({});
let
document
;
while
((
document
=
await
cursor
.
next
()))
{
const
newDoc
=
document
;
if
(
document
.
nbComputers
===
null
)
{
newDoc
.
nbComputers
=
0
;
}
if
(
document
.
nbPrinters
===
null
)
{
newDoc
.
nbPrinters
=
0
;
}
if
(
document
.
nbScanners
===
null
)
{
newDoc
.
nbScanners
=
0
;
}
if
(
document
.
nbTablets
===
null
)
{
newDoc
.
nbTablets
=
0
;
}
if
(
document
.
nbNumericTerminal
===
null
)
{
newDoc
.
nbNumericTerminal
=
0
;
}
await
db
.
collection
(
'
structures
'
).
updateOne
({
_id
:
document
.
_id
},
[{
$set
:
newDoc
}]);
}
console
.
log
(
`Update done`
);
};
export
const
down
=
async
()
=>
{
const
db
:
Db
=
await
getDb
();
const
cursor
=
db
.
collection
(
'
structures
'
).
find
({});
let
document
;
while
((
document
=
await
cursor
.
next
()))
{
const
newDoc
=
document
;
if
(
document
.
nbComputers
===
0
)
{
newDoc
.
nbComputers
=
null
;
}
if
(
document
.
nbPrinters
===
0
)
{
newDoc
.
nbPrinters
=
null
;
}
if
(
document
.
nbScanners
===
0
)
{
newDoc
.
nbScanners
=
null
;
}
if
(
document
.
nbTablets
===
0
)
{
newDoc
.
nbTablets
=
null
;
}
if
(
document
.
nbNumericTerminal
===
0
)
{
newDoc
.
nbNumericTerminal
=
null
;
}
await
db
.
collection
(
'
structures
'
).
updateOne
({
_id
:
document
.
_id
},
[{
$set
:
newDoc
}]);
}
console
.
log
(
`Update done`
);
};
This diff is collapsed.
Click to expand it.
src/structures/services/aptic-structures.service.ts
+
5
−
5
View file @
f0b382ce
...
...
@@ -80,11 +80,11 @@ export class ApticStructuresService {
createdStructure
.
publics
=
[
'
toutPublic
'
];
createdStructure
.
accountVerified
=
true
;
createdStructure
.
freeWorkShop
=
false
;
createdStructure
.
nbComputers
=
null
;
createdStructure
.
nbPrinters
=
null
;
createdStructure
.
nbScanners
=
null
;
createdStructure
.
nbTablets
=
null
;
createdStructure
.
nbNumericTerminal
=
null
;
createdStructure
.
nbComputers
=
0
;
createdStructure
.
nbPrinters
=
0
;
createdStructure
.
nbScanners
=
0
;
createdStructure
.
nbTablets
=
0
;
createdStructure
.
nbNumericTerminal
=
0
;
// Address
createdStructure
.
coord
=
[
structure
.
address
.
gpsLng
,
structure
.
address
.
gpsLat
];
createdStructure
.
address
=
this
.
formatAddress
(
structure
);
...
...
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