我正在使用MongoDB和Node.js以及mongoose和mongoose-bigdecimal。
我有一个架构:
var ethTransactionSchema = new mongoose.Schema({
blockNumber: Number,
blockHash: String,
hash: String,
transactionIndex: Number,
from: String,
to: String,
value: Schema.Types.BigDecimal,
gas: Number,
gasPrice: Schema.Types.BigDecimal
});
当我在Node.js中执行此查询时:
EthTransaction.find({$or: [{ from: "0xdd2f1e6e498202e86d8f5442af596580a4f03c2c" },
{ to: "0xdd2f1e6e498202e86d8f5442af596580a4f03c2c" }]})
.sort({ blockNumber: -1, transactionIndex: -1})
我收到的回复不完整:
{ gas: 22000,
to: '0xdd2f1e6e498202e86d8f5442af596580a4f03c2c',
from: '0x2282de79d6ae58862b6dadc22f8b4bc397adf0ef',
transactionIndex: 1,
hash: '0x19ed46ef778a4c95e440f1173ec2b13556c92a54e1a958b4c4b1509ef7cda491',
blockHash: '0x992dbd7e464c15cbe6011e1e67757d0bfc3bf4f818993aca0892f3c83a5ea2c2',
blockNumber: 802371,
_id: 570453558f9e0d385d5b6287 }
我希望从MondoDB控制台获得相同的结果:
{ "_id" : ObjectId("570453558f9e0d385d5b6287"),
"blockNumber" : 802371,
"blockHash":"0x992dbd7e464c15cbe6011e1e67757d0bfc3bf4f818993aca0892f3c83a5ea2c"
,"hash" : "0x19ed46ef778a4c95e440f1173ec2b13556c92a54e1a958b4c4b1509ef7cda491",
"transactionIndex" : 1,
"from" : "0x2282de79d6ae58862b6dadc22f8b4bc397adf0ef",
"to" : "0xdd2f1e6e498202e86d8f5442af596580a4f03c2c",
"value" : { "s" : 1, "e" : 16, "c" : [ 100 ] },
"gas" : 22000,
"gasPrice" : { "s" : 1, "e" : 10, "c" : [ 50000000000 ] } }
您可以看到第一个响应(来自Node.js)缺少值和gasPrice字段,这些字段的类型为Schema.Types.BigDecimal。 我做错了什么?