如何使用节点在mongo中插入long值? [英] How to insert long value in mongo using node?

查看:222
本文介绍了如何使用节点在mongo中插入long值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在mongo中为属性插入Long值.

I need to insert Long value for an attribute in mongo.

  var sequences = this.db.collection('sequences');
  sequences.insert( {
      _id: "TEST_SEQ",
      value: 1
  }, done);

但这是将值插入为整数,如何使其变长?

But this is inserting value as integer, how to make it Long?

推荐答案

使用mongodb Long类.像这样的东西.

Use mongodb Long class. Something like this.

const Long = require('mongodb').Long;

var sequences = this.db.collection('sequences');
sequences.insert( {
    _id: "TEST_SEQ",
    value: Long.fromInt(1)
}, done);

此处了解更多详情

Mongo-db具有提供值的默认类型,这就是为什么将其作为整数插入的原因.

Mongo-db has default types it gives values, That's why it's inserted as an integer.

这篇关于如何使用节点在mongo中插入long值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆