Skip to content

Instantly share code, notes, and snippets.

@ccho-mongodb
ccho-mongodb / PublisherHelpers.java
Created October 12, 2023 17:50
Shows various ways we could document code snippets that need to show output in documentation for the Java Reactive Streams driver by using Reactor Core as an alternative to the current helpers..
package org.example.helpers;
/*
* Copyright 2008-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
:orphan:
===========================
Code Block Indentation Test
===========================
Test page to observe the behavior of two different indentation levels for
the ``code-block`` component.
First example (``java`` syntax highlighting and line ``6`` emphasized):
@ccho-mongodb
ccho-mongodb / gist:f0de02e68f58b1da27f4ab66303f01d7
Last active December 12, 2022 19:23
Bookmarklet that opens the URL for a MongoDB JIRA ticket using the project and ticket number combo (e.g. "DOCS-123")
javascript:( function() { new Promise(setQuery => { var input = window.prompt('JIRA ticket:'); if (input) setQuery(input); }).then(query => { window.open('https://jira.mongodb.org/browse/' + query);});})();
@ccho-mongodb
ccho-mongodb / Sample output
Last active October 4, 2022 17:23
Node.js driver example for updating a document embedded in another document, all contained in an element of an array
Before:
{"_id":"633c679cfb1175cf38b5886e","name":"testDoc","items":[{"id":"a1","description":{"color":"red","size":"S"}},{"id":"a2","description":{"color":"blue","size":"L"}},{"id":"a3","description":{"color":"blue","size":"S"}}]}
After:
{"_id":"633c679cfb1175cf38b5886e","name":"testDoc","items":[{"id":"a1","description":{"color":"red","size":"S"}},{"id":"a2","description":{"color":"white","size":"L"}},{"id":"a3","description":{"color":"blue","size":"S"}}]}
#!/usr/bin/env node
const { MongoClient } = require("mongodb");
// Replace the uri string with your connection string.
const uri =
process.env.PERSONAL_MONGODB_URI;
const client = new MongoClient(uri);
@ccho-mongodb
ccho-mongodb / v1.10.json
Created July 6, 2022 19:48
Sample document from pool.repos_branches
{
_id: ObjectId("61410f680eb2cbf1ab341b31"),
repoName: 'docs-golang',
branches: [
{
name: 'master',
publishOriginalBranchName: true,
active: true,
aliases: [ 'upcoming' ],
gitBranchName: 'master',
import { MongoClient } from "mongodb";
require('dotenv').config();
const uri = (process.env.MONGODB_CONECTION_URI);
const client = new MongoClient(uri);
async function run() {
try {
await client.connect();
@ccho-mongodb
ccho-mongodb / do_stuff.json
Created August 5, 2020 03:18
Jinja templating example
{
"language": "javascript",
"versions": [{
"type": "tutorial",
"snippets": {
"id_1": " // TODO: initialize the user"
}
},
{
"type": "solution",