-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigration.js
41 lines (33 loc) · 1.09 KB
/
migration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const db = require("./database");
const { v4 } = require('uuid');
const { PlayerPokemon } = require("./Modules/Pokemon/classes");
// migration para adicionar GUID v4 nos pokemon que não tem
var PokemonPlayerDB = db.getModel("PokemonBox");
PokemonPlayerDB.find().then(async res => {
res.forEach(e => {
if(!e.pokemon) {
console.log("hm")
return;
}
if (e.pokemon.length >= 7) console.log(e);
// console.log("running migration for ", e)
// var newPokemon = [];
// e.pokemon.forEach(pokemon => {
// if(!pokemon.maxHp || !pokemon.currentHp)
// {
// var _pokemon = new PlayerPokemon (
// ...pokemon
// )
// console.log(_pokemon);
// }
// });
// console.log(newPokemon);
// PokemonPlayerDB.updateOne({
// _id: e._id,
// id: e.id
// },
// {
// pokemon: newPokemon
// }).catch(console.log).then(console.log);
})
})