import {
getState,
setState,
} from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import {
MongoClient,
ObjectId,
} from "https://deno.land/x/atlas_sdk@v1.0.3/mod.ts";
/**
* @param data_source For example: `Cluster0`
*/
type MongodbRest = {
endpoint: string;
api_key: string;
};
export async function main(
auth: MongodbRest,
data_source: string,
database: string,
collection: string,
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const documents = client.database(database).collection(collection);
const lastCheck = (await getState()) || 0;
await setState(Date.now() / 1000);
const id = ObjectId.createFromTime(lastCheck);
return await documents.find({ _id: { $gt: id } });
}
Submitted by admin 497 days ago
import { getState, setState } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { MongoClient, ObjectId } from "https://deno.land/x/atlas_sdk@v1.0.3/mod.ts";
/**
* @param data_source For example: `Cluster0`
*/
type MongodbRest = {
endpoint: string;
api_key: string;
};
export async function main(
auth: MongodbRest,
data_source: string,
database: string,
collection: string
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const documents = client.database(database).collection(collection)
const lastCheck = await getState() || 0
await setState(Date.now() / 1000)
const id = ObjectId.createFromTime(lastCheck)
return await documents.find({"_id": {"$gt": id}})
}
Submitted by admin 500 days ago
import { Resource, getState, setState } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { MongoClient, ObjectId } from "https://deno.land/x/atlas_sdk@v1.0.3/mod.ts";
/**
* @param data_source For example: `Cluster0`
*/
export async function main(
auth: Resource<"mongodb_rest">,
data_source: string,
database: string,
collection: string
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const documents = client.database(database).collection(collection)
const lastCheck = await getState() || 0
await setState(Date.now() / 1000)
const id = ObjectId.createFromTime(lastCheck)
return await documents.find({"_id": {"$gt": id}})
}
Submitted by adam186 628 days ago
import { Resource, getState, setState } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { MongoClient, ObjectId } from "https://deno.land/x/atlas_sdk@v1.0.3/mod.ts";
/**
* @param data_source For example: `Cluster0`
*/
export async function main(
auth: Resource<"mongodb_rest">,
data_source: string,
database: string,
collection: string
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const documents = client.database(database).collection(collection)
const lastCheck = await getState() || 0
await setState(Date.now() / 1000)
const id = ObjectId.createFromTime(lastCheck)
return await documents.find({"_id": {"$gt": id}})
}
Submitted by adam186 663 days ago
import { Resource, getState, setState } from "https://deno.land/x/windmill@v1.55.0/mod.ts";
import { MongoClient, ObjectId } from "https://deno.land/x/atlas_sdk@v1.0.3/mod.ts";
/**
* @param data_source For example: `Cluster0`
*/
export async function main(
auth: Resource<"mongodb_rest">,
data_source: string,
database: string,
collection: string
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const documents = client.database(database).collection(collection)
const lastCheck = await getState() || 0
await setState(Date.now() / 1000)
const id = ObjectId.createFromTime(lastCheck)
return await documents.find({"_id": {"$gt": id}})
}
Submitted by adam186 732 days ago