如何在 JavaScript shell 中將 8 位元組整數插入 MongoDB?


可以使用以下語法透過 JavaScript shell 在 MongoDB 中插入 8 位元組整數 −

anyVariableName= {"yourFieldName" : new NumberLong("yourValue")};

要顯示上述變數,可以使用變數名或 printjson()。以下是查詢,用於在 MongoDB 中插入 8 位元組整數 −

> userDetail = {"userId" : new NumberLong("98686869")};
{ "userId" : NumberLong(98686869) }

讓我們使用變數名顯示上述變數值。查詢如下 −

> userDetail

將產生以下輸出 −

{ "userId" : NumberLong(98686869) }

讓我們使用 printjson() 顯示變數值 −

> printjson(userDetail);

將產生以下輸出 −

{ "userId" : NumberLong(98686869) }

更新日期:30-Jul-2019

196 次瀏覽

助力您的職業

完成課程獲得認證

開始
廣告