Skip to content

BSON field 'OperationSessionInfo.aggregate' is a duplicate field #16

@alexz006

Description

@alexz006

How to use "aggregate"?

local mongol = require "resty-mongol"
local conn = mongol()
conn:connect('127.0.0.1', 27017)
local db = conn:new_db_handle ("test")
local col = db:get_col("test")

col:drop()

col:insert({
    {_id = 1, type = "cat", weight = 15},
    {_id = 2, type = "cat", weight = 10},
    {_id = 3, type = "cat", weight = 8.5},
    {_id = 4, type = "dog", weight = 15},
    {_id = 5, type = "dog", weight = 20},
})

local out = {}
local cursor = col:find{}
for i, item in cursor:pairs() do
    out[i] = item
end
--[[
out = [{"_id":1,"weight":15,"type":"cat"},{"_id":2,"weight":10,"type":"cat"},{"_id":3,"weight":8.5,"type":"cat"},{"_id":4,"weight":15,"type":"dog"},{"_id":5,"weight":20,"type":"dog"}]
]]

local n, err = col:aggregate({
    { ['$sort'] = {_id = -1} }
})
--[[
n = null
err = "BSON field 'OperationSessionInfo.aggregate' is a duplicate field"
]]

MongoDB server version: 4.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions