New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cookie-driver

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookie-driver

A fast and correct CookieDB driver for Node.js

  • 0.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

CookieDB for Node

A fast and correct CookieDB driver for Node

Examples for how to use this module can be found on the official documentation site

Example

const { CookieDB } = require("cookie-driver");

// Initialize instance
const cookieDB = new CookieDB(
  "http://localhost:8777",
  "UKTZOvKweOG6tyKQl3q1SZlNx7AthowA",
);

// Create a table with a schema
await cookieDB.createTable("users", {
  name: "string",
  description: "nullable string",
  age: "number",
});

// Get schema for a table
await cookieDB.metaTable("users");

// Get schemas for all table
await cookieDB.meta();

// Insert document
const cookieFanKey = await cookieDB.insert("users", {
  name: "cookie_fan",
  description: null,
  age: 20,
});

interface User {
  name: string;
  description: string | null;
  age: number;
  key: string;
}

// Get document
const cookieFan = await cookieDB.get<User>("users", cookieFanKey);

// Update document
await cookieDB.update("users", cookieFanKey, {
  description: "a huge fan of cookies",
  age: 21,
});

// Select document by query
const usersThatStartWithCookie = await cookieDB.select(
  "users",
  'starts_with($name, "cookie")',
  {
    maxResults: 5,
  },
);

// Delete document
await cookieDB.delete("users", cookieFanKey);

// Delete documents by query
await cookieDB.deleteByQuery("users", 'starts_with($name, "cookie")');

// Edit the table
await cookieDB.editTable("users", {
  name: "deprecatedUsers",
  schema: {
    name: "string",
  },
  alias: {
    name: "$name",
  },
});

// Drop the table
await cookieDB.dropTable("deprecatedUsers");

// Create a user
const { username, token } = await cookieDB.createUser({
  username: "cookie_fan",
  token: "a_very_secure_password",
});

// Regenerate a user's token
const { token: new_token } = await cookieDB.regenerateToken(
  "cookie_fan",
);

// Delete a user
await cookieDB.deleteUser("cookie_fan");

FAQs

Package last updated on 28 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc