import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.1/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,
document_id: string,
projection?: Record<string, number>,
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const db = client.database(database);
return await db
.collection(collection)
.findOne(
{ _id: new ObjectId(document_id) },
removeObjectEmptyFields({ projection }),
);
}
Submitted by admin 480 days ago
import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.1/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,
document_id: string,
projection?: Record<string, number>
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const db = client.database(database)
return await db.collection(collection).findOne(
{ _id: new ObjectId(document_id) },
removeObjectEmptyFields({ projection })
)
}
Submitted by admin 483 days ago
import { Resource } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.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,
document_id: string,
projection?: Record<string, number>
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const db = client.database(database)
return await db.collection(collection).findOne(
{ _id: new ObjectId(document_id) },
removeObjectEmptyFields({ projection })
)
}
Submitted by adam186 612 days ago
import { Resource } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.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,
document_id: string,
projection?: Record<string, number>
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const db = client.database(database)
return await db.collection(collection).findOne(
{ _id: new ObjectId(document_id) },
removeObjectEmptyFields({ projection })
)
}
Submitted by adam186 647 days ago
import { Resource } from "https://deno.land/x/windmill@v1.55.0/mod.ts";
import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.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,
document_id: string,
projection?: Record<string, number>
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const db = client.database(database)
return await db.collection(collection).findOne(
{ _id: new ObjectId(document_id) },
removeObjectEmptyFields({ projection })
)
}
Submitted by adam186 689 days ago
import { Resource } from "https://deno.land/x/windmill@v1.55.0/mod.ts";
import { MongoClient } 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,
document_id: string
) {
const client = new MongoClient({
endpoint: auth.endpoint,
dataSource: data_source,
auth: { apiKey: auth.api_key },
});
const db = client.database(database)
return await db.collection(collection).findOne({ _id: document_id })
}
Submitted by adam186 716 days ago