Skip to content

Commit 5a9d509

Browse files
committed
some adjusts
1 parent 6a52804 commit 5a9d509

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

components/neo4j_auradb/common/constants.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export const ORDER_TYPE_OPTIONS = [
66
value: "datetime",
77
},
88
{
9-
label: "Sequencial (integer)",
10-
value: "sequencial",
9+
label: "Sequential (Integer)",
10+
value: "sequential",
1111
},
1212
{
1313
label: "Other",

components/neo4j_auradb/sources/common/base.mjs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
orderBy: {
1616
type: "string",
1717
label: "Order By",
18-
description: "The property to order the nodes by including the variable. **Format: {VAR}.{FIELD}**. **Example: p.createdAt**",
18+
description: "Order By property is required for Pipedream source to identify the entity. We recommend to choose the property represent the created time property of your entity with a variable, for example createdAt.",
1919
},
2020
orderType: {
2121
type: "string",
@@ -32,10 +32,10 @@ export default {
3232
default: return "";
3333
}
3434
},
35-
_getWhereClause(lastData, type) {
35+
_getWhereClause(lastData, type, returnVariable) {
3636
switch (type) {
37-
case "datetime": return `WHERE ${this.orderBy} > datetime("${lastData}")`;
38-
case "sequencial": return `WHERE ${this.orderBy} > ${lastData}`;
37+
case "datetime": return `WHERE ${returnVariable}.${this.orderBy} > datetime("${lastData}")`;
38+
case "sequencial": return `WHERE ${returnVariable}.${this.orderBy} > ${parseInt(lastData)}`;
3939
default: return "";
4040
}
4141
},
@@ -71,10 +71,11 @@ export default {
7171
return "";
7272
},
7373
async emitEvent(maxResults = false) {
74+
const returnVariable = this.getReturnVariable();
7475
const lastData = this._getLastData();
75-
const whereClause = this._getWhereClause(lastData, this.orderType);
76-
const queryBase = this.getBaseQuery(whereClause);
77-
const query = `${queryBase} ORDER BY ${this.orderBy} DESC `;
76+
const whereClause = this._getWhereClause(lastData, this.orderType, returnVariable);
77+
const queryBase = this.getBaseQuery(whereClause, returnVariable);
78+
const query = `${queryBase} RETURN ${returnVariable} ORDER BY ${returnVariable}.${this.orderBy} DESC `;
7879

7980
const response = this.app.paginate({
8081
query,
@@ -92,9 +93,10 @@ export default {
9293
responseArray.length = maxResults;
9394
}
9495

95-
const field = this.orderBy.split(".")[1];
96-
const lastData = responseArray[0]?.properties?.[field]
97-
|| responseArray[0][1].properties[field];
96+
console.log("responseArray: ", responseArray);
97+
98+
const lastData = responseArray[0]?.properties?.[this.orderBy]
99+
|| responseArray[0][1].properties[this.orderBy];
98100

99101
this._setLastData(lastData);
100102
}

components/neo4j_auradb/sources/new-node/new-node.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ export default {
2020
methods: {
2121
...common.methods,
2222
getBaseQuery(whereClause) {
23-
const variable = this.orderBy.split(".")[0];
24-
return `MATCH (${variable}:${this.nodeLabel}) ${whereClause} RETURN ${variable} `;
23+
return `MATCH (n:${this.nodeLabel}) ${whereClause}`;
24+
},
25+
getReturnVariable() {
26+
return "n";
2527
},
2628
emit(item) {
2729
const ts = (this.orderType === "dateTime")

components/neo4j_auradb/sources/new-query-result/new-query-result.mjs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,31 @@ export default {
1313
...common.props,
1414
query: {
1515
type: "string",
16-
label: "Cypher Query",
17-
description: "The Cypher query to monitor for new results. **Example: MATCH (n:Node) RETURN n**",
16+
label: "Match Query",
17+
description: "The Cypher query to monitor for new results. **Only the MATCH query without RETURN**. **Example: MATCH (n:Node)**.",
18+
},
19+
variable: {
20+
type: "string",
21+
label: "Variable",
22+
description: "The variable you want to return from the query.",
1823
},
1924
},
2025
methods: {
2126
...common.methods,
2227
getBaseQuery() {
2328
return this.query;
2429
},
30+
getReturnVariable() {
31+
return this.variable;
32+
},
2533
emit(item) {
2634
const ts = (this.orderType === "dateTime")
27-
? Date.parse(item[1].properties[this.orderBy])
35+
? Date.parse(item.properties[this.orderBy])
2836
: new Date();
2937

3038
this.$emit(item, {
31-
id: item[1].elementId,
32-
summary: "New query result",
39+
id: item.elementId,
40+
summary: `New query result with ID: ${item.elementId}`,
3341
ts,
3442
});
3543
},

components/neo4j_auradb/sources/new-relationship/new-relationship.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ export default {
2020
methods: {
2121
...common.methods,
2222
getBaseQuery(whereClause) {
23-
const variable = this.orderBy.split(".")[0];
24-
return `MATCH _=()-[${variable}:${this.relationshipLabel}]->() ${whereClause} RETURN ${variable} `;
23+
return `MATCH _=()-[r:${this.relationshipLabel}]->() ${whereClause}`;
24+
},
25+
getReturnVariable() {
26+
return "r";
2527
},
2628
emit(item) {
2729
const ts = (this.orderType === "dateTime")

0 commit comments

Comments
 (0)