Skip to content

Instantly share code, notes, and snippets.

@sindbach
sindbach / mongodb_lookup.go
Created April 15, 2016 00:40
A simple example of how to use $lookup in Golang using mgo.
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
func main() {
session, err := mgo.Dial("localhost")
if err != nil {
@sindbach
sindbach / polymorphic_aggregation_model.cs
Last active March 13, 2024 04:27
A simple C# example to demonstrate polymorphic abstract classes to interact with MongoDB aggregation result.
using System;
using System.Linq;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Bson.Serialization.Attributes;
public abstract class MongoModelBase
{
[BsonId]
public ObjectId Id { get; set; }