GetProperty()
方法及相关类:
GetProperty(schemaName string,
propertyName string,
dbType ultipa.DBType,
config *configuration.RequestConfig
) (property *structs.Property, err error)
示例:获取test图集的点属 @client.level和边属性@transfer.amount
func TestMisc(t *testing.T) {
// 创建名为conn的连接并使用default图集,此部分代码省略
requestConfig := &configuration.RequestConfig{
GraphName: "test",
}
nodeProp, _ := conn.GetProperty("client", "level", ultipa.DBType_DBNODE, requestConfig)
fmt.Println(nodeProp)
edgeProp, _ := conn.GetProperty("transfer", "amount", ultipa.DBType_DBEDGE, requestConfig)
fmt.Println(edgeProp)
GetNodeProperty() | GetEdgeProperty()
方法及相关类:
GetNodeProperty(schemaName string,
propertyName string,
config *configuration.RequestConfig
) (property *structs.Property, err error)
GetEdgeProperty(schemaName string,
propertyName string,
config *configuration.RequestConfig
) (property *structs.Property, err error)
示例:获取test图集的点属性@client.level和边属性@transfer.amount
func TestMisc(t *testing.T) {
// 创建名为conn的连接并使用default图集,此部分代码省略
requestConfig := &configuration.RequestConfig{
GraphName: "test",
}
nodeProp, _ := conn.GetNodeProperty("client", "level", requestConfig)
fmt.Println(nodeProp)
edgeProp, _ := conn.GetEdgeProperty("transfer", "amount", requestConfig)
fmt.Println(edgeProp)
CreateProperty()
方法及相关类:
CreateProperty(schemaName string,
dbType ultipa.DBType,
prop *structs.Property,
conf *configuration.RequestConfig
) (resp *http.UQLResponse, err error)
Property struct {
Name string
Desc string
Lte bool
Schema string
Type ultipa.PropertyType
}
示例:为图集test创建边属性@transfer.amount,类型为浮点型,设置描述为transaction amount
func TestMisc(t *testing.T) {
// 创建名为conn的连接并使用default图集,此部分代码省略
requestConfig := &configuration.RequestConfig{
GraphName: "test",
}
property := &structs.Property{
Name: "amount",
Desc: "transaction amount",
Type: ultipa.PropertyType_FLOAT,
}
resp, _ := conn.CreateProperty("transfer", ultipa.DBType_DBEDGE, property, requestConfig)
log.Println(resp)
}
CreateNodeProperty() | CreateEdgeProperty()
方法及相关类:
CreateNodeProperty(schemaName string,
prop *structs.Property,
conf *configuration.RequestConfig
) (resp *http.UQLResponse, err error)
CreateEdgeProperty(schemaName string,
prop *structs.Property,
conf *configuration.RequestConfig
) (resp *http.UQLResponse, err error)
Property struct {
Name string
Desc string
Lte bool
Schema string
Type ultipa.PropertyType
}
示例:为图集test创建边属性@transfer.amount,类型为浮点型,设置描述为transaction amount
func TestMisc(t *testing.T) {
// 创建名为conn的连接并使用default图集,此部分代码省略
requestConfig := &configuration.RequestConfig{
GraphName: "test",
}
property := &structs.Property{
Name: "amount",
Desc: "transaction amount",
Type: ultipa.PropertyType_FLOAT,
}
resp, _ := conn.CreateEdgeProperty("transfer", property, requestConfig)
log.Println(resp)
}
CreatePropertyIfNotExist()
方法及相关类:
CreatePropertyIfNotExist(schemaName string,
dbType ultipa.DBType,
prop *structs.Property,
config *configuration.RequestConfig
) (exist bool, err error)
Property struct {
Name string
Desc string
Lte bool
Schema string
Type ultipa.PropertyType
}
示例:创建属性时,如果该属性已存在则返回true,否则返回false并创建
func TestMisc(t *testing.T) {
// 创建名为conn的连接并使用default图集,此部分代码省略
requestConfig := &configuration.RequestConfig{
GraphName: "test",
}
property := &structs.Property{
Name: "amount",
Desc: "transaction amount",
Type: ultipa.PropertyType_FLOAT,
}
isExist, _ := conn.CreatePropertyIfNotExist("transfer", ultipa.DBType_DBEDGE, property, requestConfig)
log.Println(isExist)
}
AlterNodeProperty() | AlterEdgeProperty()
方法及相关类:
AlterNodeProperty(propertyName string,
prop *structs.Property,
config *configuration.RequestConfig
) (resp *http.UQLResponse, err error)
AlterEdgeProperty(propertyName string,
prop *structs.Property,
config *configuration.RequestConfig
) (resp *http.UQLResponse, err error)
Property struct {
Name string
Desc string
Lte bool
Schema string
Type ultipa.PropertyType
}
示例:对图集test的点属性@client.level以及边属性@transfer.type做适当修改
func TestMisc(t *testing.T) {
// 创建名为conn的连接并使用default图集,此部分代码省略
requestConfig := &configuration.RequestConfig{
GraphName: "test",
}
nodeProp := &structs.Property{
Name: "grade",
Desc: "client grade",
}
resp1, _ := conn.AlterNodeProperty("@client.level", nodeProp, requestConfig)
log.Println(resp1)
edgeProp := &structs.Property{
Name: "category",
Desc: "transfer category",
}
resp2, _ := conn.AlterEdgeProperty("@transfer.type", edgeProp, requestConfig)
log.Println(resp2)
}
DropNodeProperty() | DropEdgeProperty()
方法及相关类:
DropNodeProperty(propertyName string, config *configuration.RequestConfig) (resp *http.UQLResponse, err error)
DropEdgeProperty(propertyName string, config *configuration.RequestConfig) (resp *http.UQLResponse, err error)
示例:删除图集test的点属性@client.grade以及边属性@transfer.category
func TestMisc(t *testing.T) {
// 创建名为conn的连接并使用default图集,此部分代码省略
requestConfig := &configuration.RequestConfig{
GraphName: "test",
}
resp1, _ := conn.DropNodeProperty("@client.grade", requestConfig)
log.Println(resp1)
resp2, _ := conn.DropEdgeProperty("@transfer.category", requestConfig)
log.Println(resp2)
}