(where: Condition)
| 63 | } |
| 64 | |
| 65 | export function serializeWhere(where: Condition): SerializedWhere { |
| 66 | if (where.type === ConditionType.Compare) { |
| 67 | return { |
| 68 | type: "Compare", |
| 69 | a: serializeColumn(where.a), |
| 70 | operator: where.operator, |
| 71 | b: where.b instanceof Column ? serializeColumn(where.b) : where.b, |
| 72 | }; |
| 73 | } |
| 74 | if (where.type === ConditionType.And || where.type === ConditionType.Or) { |
| 75 | return { |
| 76 | type: where.type === ConditionType.And ? "And" : "Or", |
| 77 | items: where.items.map(serializeWhere), |
| 78 | }; |
| 79 | } |
| 80 | if (where.type === ConditionType.Not) { |
| 81 | return { |
| 82 | type: "Not", |
| 83 | item: serializeWhere(where.item), |
| 84 | }; |
| 85 | } |
| 86 | throw new Error("Unknown condition type"); |
| 87 | } |
no test coverage detected