2026_08_31

This commit is contained in:
marco committed 2026-08-31 16:19:06 +02:00
commit 73015386e9
2320 files changed
+80291

No files matched your search

+270
View File
@@ -0,0 +1,270 @@
import { Types } from "mongoose";
export const Unit_query_get = (anlageId: string, filter?: string) => {
return [
{
$match: {
anlageId: new Types.ObjectId(anlageId)
}
},
{
$lookup: {
from: 'signals',
localField: "_id", // Feld in signals
foreignField: "signalId", // Feld in unit
let: { unitId: "$_id", anlageId: "$anlageId" },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ["$unitId", "$$unitId"] },
{ $eq: ["$anlageId", "$$anlageId"] }
]
}
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
_id: 0, // weg
anlageId: 0, // weg
groupId: 0 // weg
}
},
],
as: "signals"
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
id: 1,
_id: 0,
anlageId: 1,
name: 1,
type: 1,
nr: 1,
funcTxt: 1,
displayName: 1,
ort: 1,
info: 1,
options: 1,
elements: 1
}
},
{
$sort: {
nr: 1 as 1
}
}
];
}
export const Unit_query_getSAVE = (anlageId: string, filter?: string) => {
return [
{
$match: {
anlageId: new Types.ObjectId(anlageId)
}
},
{
$lookup: {
from: 'signals',
localField: "_id", // Feld in signals
foreignField: "signalId", // Feld in unit
let: { unitId: "$_id", anlageId: "$anlageId" },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ["$unitId", "$$unitId"] },
{ $eq: ["$anlageId", "$$anlageId"] }
]
}
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
_id: 0, // weg
anlageId: 0, // weg
groupId: 0 // weg
}
},
],
as: "signals"
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
id: 1,
_id: 0,
anlageId: 1,
name: 1,
type: 1,
nr: 1,
funcTxt: 1,
displayName: 1,
ort: 1,
info: 1,
options: 1,
elements: 1
}
},
{
$sort: {
nr: 1 as 1
}
}
];
}
export const Group_query_get_with_elements =
[
{
$lookup: {
from: 'elements',
localField: "_id", // Feld in users
foreignField: "groupId", // Feld in posts
let: { groupId: "$_id", anlageId: "$anlageId" },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ["$groupId", "$$groupId"] },
{ $eq: ["$anlageId", "$$anlageId"] }
]
}
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
_id: 0, // weg
anlageId: 0, // weg
groupId: 0 // weg
}
}
],
as: "elements"
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
id: 1,
_id: 0,
name: 1,
type: 1,
nr: 1,
funcTxt: 1,
displayName: 1,
ort: 1,
info: 1,
options: 1,
elements: 1
}
}
];
export const Group_query_get_with_peripherie =
[
{
$lookup: {
from: 'peripheries',
localField: "_id", // Feld in users
foreignField: "groupId", // Feld in posts
let: { groupId: "$_id", anlageId: "$anlageId" },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ["$groupId", "$$groupId"] },
{ $eq: ["$anlageId", "$$anlageId"] }
]
}
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
_id: 0, // weg
adrType: 1,
adrByte: 1,
adrBit: 1,
karte: 1,
text: 1,
seite: 1,
seiteName: 1,
}
}
],
as: "peripheries"
}
},
{
$addFields: {
id: "$_id"
}
},
{
$project: {
id: 1,
_id: 0,
name: 1,
type: 1,
nr: 1,
funcTxt: 1,
displayName: 1,
ort: 1,
info: 1,
options: 1,
peripheries: 1
}
}
]