Skip to content

Instantly share code, notes, and snippets.

@ma6174
Created April 8, 2014 05:43
Show Gist options
  • Select an option

  • Save ma6174/10094894 to your computer and use it in GitHub Desktop.

Select an option

Save ma6174/10094894 to your computer and use it in GitHub Desktop.
mongo bson
var allItems = []testItemType{
{bson.M{},
""},
{bson.M{"_": float64(5.05)},
"\x01_\x00333333\x14@"},
{bson.M{"_": "yo"},
"\x02_\x00\x03\x00\x00\x00yo\x00"},
{bson.M{"_": bson.M{"a": true}},
"\x03_\x00\x09\x00\x00\x00\x08a\x00\x01\x00"},
{bson.M{"_": []interface{}{true, false}},
"\x04_\x00\r\x00\x00\x00\x080\x00\x01\x081\x00\x00\x00"},
{bson.M{"_": []byte("yo")},
"\x05_\x00\x02\x00\x00\x00\x00yo"},
{bson.M{"_": bson.Binary{0x80, []byte("udef")}},
"\x05_\x00\x04\x00\x00\x00\x80udef"},
{bson.M{"_": bson.Undefined}, // Obsolete, but still seen in the wild.
"\x06_\x00"},
{bson.M{"_": bson.ObjectId("0123456789ab")},
"\x07_\x000123456789ab"},
{bson.M{"_": false},
"\x08_\x00\x00"},
{bson.M{"_": true},
"\x08_\x00\x01"},
{bson.M{"_": time.Unix(0, 258e6)}, // Note the NS <=> MS conversion.
"\x09_\x00\x02\x01\x00\x00\x00\x00\x00\x00"},
{bson.M{"_": nil},
"\x0A_\x00"},
{bson.M{"_": bson.RegEx{"ab", "cd"}},
"\x0B_\x00ab\x00cd\x00"},
{bson.M{"_": bson.JavaScript{"code", nil}},
"\x0D_\x00\x05\x00\x00\x00code\x00"},
{bson.M{"_": bson.Symbol("sym")},
"\x0E_\x00\x04\x00\x00\x00sym\x00"},
{bson.M{"_": bson.JavaScript{"code", bson.M{"": nil}}},
"\x0F_\x00\x14\x00\x00\x00\x05\x00\x00\x00code\x00" +
"\x07\x00\x00\x00\x0A\x00\x00"},
{bson.M{"_": 258},
"\x10_\x00\x02\x01\x00\x00"},
{bson.M{"_": bson.MongoTimestamp(258)},
"\x11_\x00\x02\x01\x00\x00\x00\x00\x00\x00"},
{bson.M{"_": int64(258)},
"\x12_\x00\x02\x01\x00\x00\x00\x00\x00\x00"},
{bson.M{"_": int64(258 << 32)},
"\x12_\x00\x00\x00\x00\x00\x02\x01\x00\x00"},
{bson.M{"_": bson.MaxKey},
"\x7F_\x00"},
{bson.M{"_": bson.MinKey},
"\xFF_\x00"},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment