mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
default key ascending
This commit is contained in:
@@ -344,7 +344,13 @@ local function IndexModel(option)
|
|||||||
local keys = {}
|
local keys = {}
|
||||||
local name
|
local name
|
||||||
for _, kv in ipairs(option) do
|
for _, kv in ipairs(option) do
|
||||||
local k,v = next(kv)
|
local k,v
|
||||||
|
if type(kv) == "string" then
|
||||||
|
k = kv
|
||||||
|
v = 1
|
||||||
|
else
|
||||||
|
k,v = next(kv)
|
||||||
|
end
|
||||||
table.insert(keys, k)
|
table.insert(keys, k)
|
||||||
table.insert(keys, v)
|
table.insert(keys, v)
|
||||||
name = (name == nil) and k or (name .. "_" .. k)
|
name = (name == nil) and k or (name .. "_" .. k)
|
||||||
@@ -358,6 +364,8 @@ local function IndexModel(option)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- collection:createIndex { { key1 = 1}, { key2 = 1 }, unique = true }
|
-- collection:createIndex { { key1 = 1}, { key2 = 1 }, unique = true }
|
||||||
|
-- or collection:createIndex { "key1", "key2", unique = true }
|
||||||
|
-- or collection:createIndex( { key1 = 1} , { unique = true } ) -- For compatibility
|
||||||
function mongo_collection:createIndex(arg1 , arg2)
|
function mongo_collection:createIndex(arg1 , arg2)
|
||||||
if arg2 then
|
if arg2 then
|
||||||
return createIndex_onekey(self, arg1, arg2)
|
return createIndex_onekey(self, arg1, arg2)
|
||||||
|
|||||||
Reference in New Issue
Block a user