Skip to content

Commit

Permalink
Update database.md
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-dvorak authored Mar 12, 2024
1 parent 3e6556c commit 8525eca
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions database.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,59 @@ db.createView("packets_count_complete", "stock", [
}
])
```


### Kategorie a view

```
db.category_complete.drop();
db.category.aggregate([
{
"$graphLookup": {
"from": "store_positions",
"startWith": "$parent",
"connectFromField": "parent",
"connectToField": "_id",
"as": "path"
}
},
{
"$set": {
"path": {
"$reverseArray": "$path"
}
}
},
{
"$addFields": {
"path_string": "$path.name"
}
},
{
"$addFields": {
"icon_url": {
"$switch": {
"branches": [
{
"case": {
"$eq": ["$icon_source", "null"]
},
"then": "null"
},
{
"case": {
"$eq": ["$icon_source", "electronic-symbols"]
},
"then": {
"$concat": ["/static/electronic-symbols/SVG/", "$icon", ".svg"]
}
}
],
"default": "null"
}
}
}
}
]).saveAsView("category_complete");
```

0 comments on commit 8525eca

Please sign in to comment.