Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将如何在 mongo 中以原子方式将值添加到数组的开头?
感谢您的任何指导。
你不能按照这张票直接做。
您现在唯一的选择是获取数组,将元素放在开头并再次将其放入 mongo。
someArray.unshift(someValue);
例如
> x = [1,2,3] [1, 2, 3] > x.unshift(0) 4 > x [0, 1, 2, 3]