Skip to content

Commit 16d9788

Browse files
authored
MongoDB - update to new-document source (#16820)
* updates * pnpm-lock.yaml * remove console.log * update
1 parent c47dadd commit 16d9788

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
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: 18 additions & 3 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,17 @@ 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+
default: "Timestamp",
39+
options: [
40+
"Timestamp",
41+
"Integer",
42+
],
3343
},
3444
},
3545
hooks: {
@@ -49,6 +59,9 @@ export default {
4959
},
5060
getTs(doc) {
5161
const tsValue = doc[this.timestampField];
62+
if (this.timestampFieldType === "Integer") {
63+
return tsValue;
64+
}
5265
if (typeof tsValue === "string") {
5366
return new Date(tsValue).getTime();
5467
}
@@ -77,7 +90,9 @@ export default {
7790
};
7891
const query = {
7992
[this.timestampField]: {
80-
$gt: this.convertToTimestamp(lastTs),
93+
$gt: this.timestampFieldType === "Integer"
94+
? lastTs
95+
: this.convertToTimestamp(lastTs),
8196
},
8297
};
8398
const documents = await collection.find(query).sort(sort)

pnpm-lock.yaml

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)