[][src]Constant tari_storage::lmdb_store::db::REVERSEKEY

pub const REVERSEKEY: Flags;

Keys are strings to be compared in reverse order, from the end of the strings to the beginning. By default, Keys are treated as strings and compared from beginning to end.

NOTE: This is not reverse sort, but rather right-to-left comparison.

Example

let db = lmdb::Database::open(
  &env, Some("reversed"), &lmdb::DatabaseOptions::new(
    lmdb::db::REVERSEKEY | lmdb::db::CREATE)).unwrap();
let txn = lmdb::WriteTransaction::new(&env).unwrap();
{
  let mut access = txn.access();
  let f = lmdb::put::Flags::empty();
  access.put(&db, "Germany", "Berlin", f).unwrap();
  access.put(&db, "Latvia", "Rīga", f).unwrap();
  access.put(&db, "France", "Paris", f).unwrap();

  let mut cursor = txn.cursor(&db).unwrap();
  // The keys are compared as if we had input "aivtaL", "ecnarF",
  // and "ynamreG", so "Latvia" comes first and "Germany" comes
  // last.
  assert_eq!(("Latvia", "Rīga"), cursor.first(&access).unwrap());
  assert_eq!(("Germany", "Berlin"), cursor.last(&access).unwrap());
}
txn.commit().unwrap();