thinkjs的select,find,getField

getField:

.getField('groupId', true)  //3
.getField('groupId', true)  //undefined
.getField('groupId', false)) //[ 3 ]
.getField('groupId', false)) // []
.getField('groupId, userId', false))  // { groupId: [], userId: [] }
getField('groupId, userId', false)) // { groupId: [ 3 ], userId: [ 10001339 ] }
getField('groupId, userId', true)) // { groupId: undefined, userId: undefined }
getField('groupId, userId', true)) // { groupId: 3, userId: 10001339 }

find:

只返回一行,没有满足条件的记录时不论.field怎么填都返回{}
field的第二个参数true代表不包含第一个参数的列,反向选择

.field('groupId', true).find() // RowDataPacket { id: 4, userId: 10001339, starId: 4163 }
.field('groupId', false).find()) // RowDataPacket { groupId: 3 }
.field('groupId, userId', true).find()) // RowDataPacket { id: 4, starId: 4163 }
.field('groupId, userId', false).find()) // RowDataPacket { groupId: 3, userId: 10001339 }

select

返回行数组,如果没有符合的就返回[]

.field('groupId', true).find() // [RowDataPacket { id: 4, userId: 10001339, starId: 4163 }]
.field('groupId', false).find()) // [RowDataPacket { groupId: 3 }]
.field('groupId, userId', true).find()) // [RowDataPacket { id: 4, starId: 4163 }]
.field('groupId, userId', false).find()) // [RowDataPacket { groupId: 3, userId: 10001339 }]
上一篇:Maven依赖管理


下一篇:dataframe 基本操作