我最近升级到Node 5.4和MongoDb 2.1.4 Driver for Node,我遇到了以下问题:
我有一个名为buildings.json的文件,其中包含以下内容:
{
"military_base": {
"type": "military",
"level": 0,
"maxLevel": 25,
"upgrade": true,
"targetEnvironment": [],
"timeUntilBuilt": 0,
"costCoef": 0.4,
"requiredResearches": [
"foo#4",
"bar#1"
],
"requiredResources": [
"cash",
"metal",
"palladium"
],
"inProgress": 0,
"queue": []
},
"aqua_center": {
"type": "industrial",
"level": 0,
"maxLevel": 25,
"upgrade": true,
"targetEnvironment": [
"ocean",
"snowy"
],
"timeUntilBuilt": 0,
"costCoef": 0.7,
"requiredResearches": [
"lorem#10",
"ipsum#3"
],
"requiredResources": [
"cash",
"cristal"
],
"inProgress": 0,
"queue": []
}
}
现在,我想将此文档插入到mongo数据库中:
let buildings = require( "buildings" );
...
collection.insertOne( { foo: buildings }, callback );
如果第一个"targetEnvironment"
数组为空,则不插入任何内容,则不会调用回调,也不会出现错误。但如果它已经填满,一切都很好,调用回调并正确插入文档......
我必须承认,我不知道问题是否与Node或MongoDb驱动程序有关......
有人可以帮帮我吗?
答案 0 :(得分:0)
def surface():
global zone1rect
global zone2rect
global zone3rect
global bl
global prect
zone1rect
zone2rect
zone3rect
bl
prect = pygame.draw.rect(SURF, (0,0,0), (p_spritex, p_spritey, 30, 40), 1)
SURF.blit(background,(0,0))
SURF.blit(p_sprite,(p_spritex,p_spritey))
surface()
如果我尝试插入此文档,则不会插入该文档,因为第一个costCoef属性是浮点数。如果它是一个像时间戳这样的大数字,它也会失败。
答案 1 :(得分:0)
哦......因为我有64位Windows,我安装了64位nodejs版本,问题来自这里......有32位,没有错误! :○