Readme

Demo of mongo-http NPM package

  • Great for serverless apps that can only use HTTP or have a hard time persisting database connection
  • See more at the Git Repo and the Medium tutorial!
  • What this demo does: Read the latest Chinese Medium posts with categories "javascript" or "typescript"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import process from "node:process";
export const readMediumPosts = (async () => {
const { initDatabase } = await import("npm:mongo-http");
const articlesDatabase = initDatabase({
appId: process.env.MONGODB_ARTICLES_APP_ID,
apiKey: process.env.MONGODB_ARTICLES_API_KEY,
databaseName: "medium",
});
const results = await articlesDatabase.collection("articles").find({
filter: { categories: { $in: ["javascript", "typescript"] } },
projection: {
_id: 0,
creator: 1,
title: 1,
pubDate: 1,
guid: 1,
categories: 1,
},
sort: { isoDateTs: -1 },
limit: 30,
});
return results;
})();
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023