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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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": [
Expand Down
20 changes: 17 additions & 3 deletions components/mongodb/sources/new-document/new-document.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -29,7 +29,16 @@ 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",
options: [
"Timestamp",
"Integer",
],
},
},
hooks: {
Expand All @@ -49,6 +58,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();
}
Expand Down Expand Up @@ -77,7 +89,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)
Expand Down
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.

Loading