Proper way to check operational data list existence

Hi,

I have the following data model,
container device {

list meas {
config false;
key rnti;
leaf rnti {
type int;
}
leaf data {
config false;
type int;
}

}
}
The meas is an operational data list and it will get updated periodically. What I want to achieve is to delete all entries before adding new ones. Since the key, rnti, may be different each time, it is difficult to check existence of specific entry. I tried to use cdb_exists with path “/device/meas” to check if there is any entry exists, but it always give me true even there is no entry in the list.

I know I can use cdb_num_instances to check /device/meas and it will give me zero if there nothing. But from the UG, it says,

int cdb_exists(int sock, const char *fmt, …);
Leafs in the data model may be optional, and presence containers and list entries may or may not exist.
This function checks whether a node exists in CDB. Returns 0 for false, 1 for true and CONFD_ERR or
CONFD_EOF for errors.

Can anyone point me the correct usage of this API?

Thanks

A list entry is a path to a list that includes list keys. Example:
cdb_exists(mysock, "/device/meas(42}")
Note that wrapping lists with a container allow you to delete just the container to delete all list entries.

OK, that is what I guessed. I will use cdb_num_instances instead.
Thank you for help.