Skip to content

MongoDB - update to new-document source #16820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/mongodb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/mongodb",
"version": "0.1.2",
"version": "0.1.3",
"description": "Pipedream MongoDB Components",
"main": "mongodb.app.mjs",
"keywords": [
21 changes: 18 additions & 3 deletions components/mongodb/sources/new-document/new-document.mjs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ export default {
key: "mongodb-new-document",
name: "New Document",
description: "Emit new an event when a new document is added to a collection",
version: "0.0.10",
version: "0.0.11",
type: "source",
dedupe: "unique",
props: {
@@ -29,7 +29,17 @@ export default {
timestampField: {
type: "string",
label: "Timestamp Field",
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.",
description: "The key of a timestamp field, such as 'created_at' that is set to the current timestamp when a document is created.",
},
timestampFieldType: {
type: "string",
label: "Timestamp Field Type",
description: "The type of the timestamp field",
default: "Timestamp",
options: [
"Timestamp",
"Integer",
],
},
},
hooks: {
@@ -49,6 +59,9 @@ export default {
},
getTs(doc) {
const tsValue = doc[this.timestampField];
if (this.timestampFieldType === "Integer") {
return tsValue;
}
if (typeof tsValue === "string") {
return new Date(tsValue).getTime();
}
@@ -77,7 +90,9 @@ export default {
};
const query = {
[this.timestampField]: {
$gt: this.convertToTimestamp(lastTs),
$gt: this.timestampFieldType === "Integer"
? lastTs
: this.convertToTimestamp(lastTs),
},
};
const documents = await collection.find(query).sort(sort)
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.