surrealdb-core 3.2.2

A scalable, distributed, collaborative, document-graph database, for the realtime web
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::sync::Arc;

use crate::ctx::{Context, FrozenContext};
use crate::dbs::Options;
use crate::iam::{Auth, Role};
use crate::kvs::Datastore;
use crate::kvs::LockType::*;
use crate::kvs::TransactionType::*;

pub async fn mock() -> (FrozenContext, Options) {
	let kvs = Datastore::new("memory").await.unwrap();
	let opt = Options::new(&kvs.config()).with_auth(Arc::new(Auth::for_root(Role::Owner)));
	let txn = kvs.transaction(Write, Optimistic).await.unwrap().enclose();
	let mut ctx = Context::new_test();
	ctx.set_transaction(txn);
	(ctx.freeze(), opt)
}