将neo4j Integer对象转换为JavaScript Integer
我正在neo4j中将将neo4j Integer对象转换为JavaScript Integer,javascript,neo4j,Javascript,Neo4j,我正在neo4j中将dateBirth存储为毫秒 使用浏览器时,我得到以下信息: match (u:User) return u.dateBirth // Returns -2209078800000 match (u:User) return toInt(u.dateBirth) as dateBirth // Returns: Integer { low: -1465609856, high: -515 } 使用螺栓驱动程序(neo4j v3 javascript)时,我得到以下结果:
dateBirth
存储为毫秒
使用浏览器时,我得到以下信息:
match (u:User) return u.dateBirth // Returns -2209078800000
match (u:User) return toInt(u.dateBirth) as dateBirth
// Returns: Integer { low: -1465609856, high: -515 }
使用螺栓驱动程序(neo4j v3 javascript)时,我得到以下结果:
match (u:User) return u.dateBirth // Returns -2209078800000
match (u:User) return toInt(u.dateBirth) as dateBirth
// Returns: Integer { low: -1465609856, high: -515 }
如何将此整数对象转换为JavaScript中的基本数字?如中所述:
Neo4j型系统包括64位整数值。但是,Javascript只能安全地表示介于-(2^53-1)和(2^53-1)之间的整数。为了支持完整的Neo4j类型系统,驱动程序包含一个显式整数类型。每当驱动程序从Neo4j接收到一个整数值时,驱动程序就会用整型来表示它
您可以使用toInt()
(假设为32位整数)或toNumber()
转换为最接近的浮点JavaScript数字类型
整型
类型的详细文档可用。我正在使用中的此函数。到目前为止效果很好
函数toNumber({low,high}){
设res=高
for(设i=0;i<32;i++){
res*=2
}
返回低+分辨率
}
如果使用toFloat
而不是toInt
,会发生什么?在驱动程序自述文件中有一个关于整数的文档,使用toFloat()而不是toInt()可能会重复match(u:User)将toFloat(u.dateBirth)返回为dateBirth
此链接非常有用。你在哪里找到的?