这是结构。我有一个主节点,内部是keys。如何检查该节点内部是否存在特定的key?
apiVersion: v1
items:
- apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
creationTimestamp: 2018-07-19T14:33:00Z
generation: 1
name: bookinfo
namespace: default
resourceVersion: "27242"
selfLink: /apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/bookinfo
uid: a3238ced-8b60-11e8-8bbd-080027f49aa7
spec:
gateways:
- bookinfo-gateway
hosts:
- '*'
http:
- match:
- uri:
exact: /productpage
- uri:
exact: /login
- uri:
exact: /logout
- uri:
prefix: /api/v1/products
route:
- destination:
host: productpage
port:
number: 9080
- apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
creationTimestamp: 2018-07-26T07:25:08Z
generation: 1
name: details
namespace: default
resourceVersion: "165316"
selfLink: /apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/details
uid: 068c51e2-90a5-11e8-84d8-080027f49aa7
spec:
hosts:
- details
http:
- route:
- destination:
host: details
subset: v1
- apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
creationTimestamp: 2018-07-26T07:25:08Z
generation: 1
name: productpage
namespace: default
resourceVersion: "165313"
selfLink: /apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/productpage
uid: 0688fb66-90a5-11e8-84d8-080027f49aa7
spec:
gateways:
- bookinfo
hosts:
- productpage
http:
- route:
- destination:
host: productpage
subset: v1
- apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
creationTimestamp: 2018-07-26T07:25:08Z
generation: 1
name: ratings
namespace: default
resourceVersion: "165315"
selfLink: /apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/ratings
uid: 068b1107-90a5-11e8-84d8-080027f49aa7
spec:
hosts:
- ratings
http:
- route:
- destination:
host: ratings
subset: v1
- apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
creationTimestamp: 2018-07-26T07:25:08Z
generation: 1
name: reviews
namespace: default
resourceVersion: "166771"
selfLink: /apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/reviews
uid: 068a454e-90a5-11e8-84d8-080027f49aa7
spec:
hosts:
- reviews
http:
- match:
- headers:
cookie:
regex: ^(.*?;)?(user=mariam)(;.*)?$
route:
- destination:
host: reviews
subset: v2
- route:
- destination:
host: reviews
subset: v1
kind: List
metadata:
resourceVersion: ""
selfLink: ""
答案 0 :(得分:2)
有一个exists函数可以调用。
let ref = firebase.database().ref('yourNode/yourKey');
ref.once("value")
.then(function(snapshot) {
console.log(snapshot.exists()); // true
}