Namespace
Creates a namespaced database instance.
- Parameters:
name
: The name of the namespace.
- Returns:
- A new database instance with the namespace applied.
// Create a new database instance
const db = new MiftahDB(":memory:");
// Make a namespaced database instance
const users = db.namespace("users");
const posts = db.namespace("posts");
const comments = db.namespace("comments");
// Set/Get a value with a namespace
users.set("852335", { name: "Ahmad" });
console.log(users.get("852335"));
// Will count the keys only on the "users" namespace only
users.count();
// Will remove expired keys only on the "users" namespace only
users.cleanup();
// Will remove all keys only on the "users" namespace only
users.flush();