Skip to main content

encode_pk

Function encode_pk 

Source
pub fn encode_pk(values: &[KeyComponent]) -> String
Expand description

Encode a primary key value.

For single-column keys this returns a single component; for composite keys the components are joined with :.

ยงExample

use mongreldb_kit_core::keys::{encode_pk, KeyComponent};
assert_eq!(encode_pk(&[KeyComponent::text("hello")]), "s:hello");
assert_eq!(encode_pk(&[KeyComponent::Int(1)]), "i:1");
assert_eq!(
    encode_pk(&[KeyComponent::text("a"), KeyComponent::text("b")]),
    "s:a:s:b"
);