Skip to content

Instantly share code, notes, and snippets.

View topuhit's full-sized avatar
👨‍💻

Md Tariqul Islam topuhit

👨‍💻
View GitHub Profile
@topuhit
topuhit / index.js
Created July 22, 2022 09:45 — forked from schfl0/index.js
[MongoDB API Endpoints] GET, POST, PUT, DELETE #sveltekit #svelte #mongodb #endpoints #get #post #put #delete #del #api
import { connectToDatabase } from '$lib/db';
import { ObjectId } from 'mongodb';
export async function get(request) {
try {
const completed = request.query.get('completed') === 'true' ? true : false;
const dbConnection = await connectToDatabase();
const db = dbConnection.db;
const collection = db.collection('sveltetodos');
const todos = await collection.find({ completed }).toArray();