Skip to content

Commit 2172fdc

Browse files
committed
updates
1 parent cf6fdea commit 2172fdc

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

components/mongodb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/mongodb",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Pipedream MongoDB Components",
55
"main": "mongodb.app.mjs",
66
"keywords": [

components/mongodb/sources/new-document/new-document.mjs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "mongodb-new-document",
77
name: "New Document",
88
description: "Emit new an event when a new document is added to a collection",
9-
version: "0.0.10",
9+
version: "0.0.11",
1010
type: "source",
1111
dedupe: "unique",
1212
props: {
@@ -29,7 +29,16 @@ export default {
2929
timestampField: {
3030
type: "string",
3131
label: "Timestamp Field",
32-
description: "The key of a timestamp field, such as 'created_at' that is set to the current timestamp when a document is created. Must be of type Timestamp.",
32+
description: "The key of a timestamp field, such as 'created_at' that is set to the current timestamp when a document is created.",
33+
},
34+
timestampFieldType: {
35+
type: "string",
36+
label: "Timestamp Field Type",
37+
description: "The type of the timestamp field",
38+
options: [
39+
"Timestamp",
40+
"Integer",
41+
],
3342
},
3443
},
3544
hooks: {
@@ -49,6 +58,9 @@ export default {
4958
},
5059
getTs(doc) {
5160
const tsValue = doc[this.timestampField];
61+
if (this.timestampFieldType === "Integer") {
62+
return tsValue;
63+
}
5264
if (typeof tsValue === "string") {
5365
return new Date(tsValue).getTime();
5466
}
@@ -77,14 +89,16 @@ export default {
7789
};
7890
const query = {
7991
[this.timestampField]: {
80-
$gt: this.convertToTimestamp(lastTs),
92+
$gt: this.timestampFieldType === "Integer"
93+
? lastTs
94+
: this.convertToTimestamp(lastTs),
8195
},
8296
};
8397
const documents = await collection.find(query).sort(sort)
84-
.toArray();
98+
.toArray(); console.log(documents);
8599
const docs = [];
86100
for (const doc of documents) {
87-
const ts = this.getTs(doc);
101+
const ts = this.getTs(doc); console.log(ts);
88102
if (!(ts > lastTs) || (max && count >= max)) {
89103
break;
90104
}

0 commit comments

Comments
 (0)