Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pepeul1191/sqlite-to-mongodb
https://github.com/pepeul1191/sqlite-to-mongodb
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/pepeul1191/sqlite-to-mongodb
- Owner: pepeul1191
- Created: 2023-07-04T05:52:44.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-01T04:39:07.000Z (about 1 year ago)
- Last Synced: 2023-12-01T05:30:49.608Z (about 1 year ago)
- Language: Python
- Size: 145 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Migraciones
Migraciones con DBMATE:
$ dbmate -d "migrations" -e "DB" new <>
$ dbmate -d "migrations" -e "DB" up
$ dbmate -d "migrations" -e "DB" rollback### Consultas MongoDB
``` javascript
// proyección
db.getCollection("pokemon_types").find({},{name: 1, _id: 0})
// seleccionar todos
db.getCollection("pokemon_types").find()
// quitar campo
db.nombre_coleccion.updateMany({}, { $unset: { nombre_campo: "" } })
// insertar varios
db.pokemon_types.insertMany([
{"id": 1, "name": "PLANTA"},
{"id": 2, "name": "VENENO"},...
])
// contar
db.locations.find({'type': 'department'}).count()
// borrar colección
db.pokemon_types.drop()
// borrar documentos - todos
db.locations.deleteMany({})
// find in array
db.pokemon_types.find({ id: { $in: ['1', '2'] } })
// joins?
db.pokemons.aggregate([
{
$lookup: {
from: "generations",
localField: "generation_id",
foreignField: "_id",
as: "generation"
}
},
{
$project: {
"id: 0,
"generation_id": 0
}
},
{
$addFields: {
generation: { $arrayElemAt: ["$generation", 0] }
}
},
{
$unwind: "$pokemon_types"
},
{
$lookup: {
from: "pokemon_types",
localField: "pokemon_types",
foreignField: "_id",
as: "pokemon_types"
}
},
{
$addFields: {
pokemon_types: { $arrayElemAt: ["$pokemon_types", 0] }
}
},])
```