图数据库(十二):Neo4j中数据类型及部分数据类型转换函数

数据类型可以分为三大类:

属性类型

  • 数值类Integer 和 Float
  • 字符类:String
  • 布尔类:Boolean
  • 空间类Point
  • 时间类DateTimeLocalTimeDateTimeLocalDateTime 和 Duration

结构类型

  • 节点类:Node(包含Id,Labels, Map类型)
  • 关系类:Relationship(包含Type, Map, Id类型)
  • 路径类:Path(节点和关系的序列)

组成类型

  • 列表类:List
  • 字典类:Map [组成为(key, value)对,key是字符类型,value可以是属性类型,结构类型和组成类型。]

类型转换

toBoolean()

toBooleanOrNull()

toBoolean() 函数将字符串、整数或布尔值转换为布尔值。

RETURN toBoolean('true'), toBoolean('not a boolean'), toBoolean(0)

结果

toBoolean('true') toBoolean('not a boolean') toBoolean(0)

true

<null>

false

toBooleanOrNull() 函数将字符串、整数或布尔值转换为布尔值。 对于任何其他输入值,将返回 null。
RETURN toBooleanOrNull('true'), toBooleanOrNull('not a boolean'), toBooleanOrNull(0), toBooleanOrNull(1.5)

结果

toBooleanOrNull('true')

toBooleanOrNull('not a boolean')

toBooleanOrNull(0)

toBooleanOrNull(1.5)

true

<null>

false

<null>

toFloat()

toFloatOrNull()

toFloat() 函数将整数、浮点数或字符串值转换为浮点数。

RETURN toFloat('11.5'), toFloat('not a number')

结果

toFloat('11.5') toFloat('not a number')

11.5

<null>

toFloatOrNull() 函数将整数、浮点或字符串值转换为浮点数。 对于任何其他输入值,将返回 null。
RETURN toFloatOrNull('11.5'), toFloatOrNull('not a number'), toFloatOrNull(true)

结果

toFloatOrNull('11.5') toFloatOrNull('not a number') toFloatOrNull(true)

11.5

<null>

<null>

toInteger()

toIntegerOrNull()

 函数 toInteger() 将布尔值、整数、浮点数或字符串值转换为整数值。

RETURN toInteger('42'), toInteger('not a number'), toInteger(true)

结果

toInteger('42') toInteger('not a number') toInteger(true)

42

<null>

1

toIntegerOrNull() 函数将布尔值、整数、浮点数或字符串值转换为整数值。 对于任何其他输入值,将返回 null。

RETURN toIntegerOrNull('42'), toIntegerOrNull('not a number'), toIntegerOrNull(true), toIntegerOrNull(['A', 'B', 'C'])

结果

toIntegerOrNull('42') toIntegerOrNull('not a number') toIntegerOrNull(true) toIntegerOrNull(['A', 'B', 'C'])

42

<null>

1

<null>

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值