Skip to main content

A simple Python package for managing space availability in Convex

Project description

Convex Space Manager

A simple Python package for managing space availability in Convex databases.

Features

  • 🚀 Simple API - Easy-to-use interface for space management
  • 🔄 Batch Updates - Update multiple spaces at once
  • Real-time - Instant updates to your Convex database
  • 📦 Lightweight - Minimal dependencies, just Python + Convex
  • 🛠️ Flexible - Works with any space naming convention

Installation

pip install convex-space-manager

Quick Start

from convex_space_manager import convex_sync

# Your space data
spaces = ["space1", "space2", "space3", "space4", "space5"]
availability = [True, False, True, False, True]  # True = full, False = available

# Update all spaces at once
convex_sync(availability, spaces, "https://your-deployment.convex.cloud")

Advanced Usage

from convex_space_manager import ConvexSpaceManager

# Initialize manager
manager = ConvexSpaceManager("https://your-deployment.convex.cloud")

# Update individual spaces
manager.update_space("space1", True)   # space1 is now full
manager.update_space("space2", False)  # space2 is now available

# Update multiple spaces
spaces = ["space1", "space2", "space3"]
availability = [True, False, True]
manager.update_multiple_spaces(spaces, availability)

Requirements

  • Python 3.7+
  • Convex deployment URL
  • Convex database with spaces table containing spaceName and isFull fields

Convex Schema

Your Convex database should have a spaces table with this structure:

spaces: defineTable({
  spaceName: v.string(),
  isFull: v.boolean(),
}).index("by_spaceName", ["spaceName"])

And a mutation function:

export const update_fullness = mutation({
  args: {
    spaceName: v.string(),
    isFull: v.boolean(),
  },
  handler: async (ctx, args) => {
    const existingSpace = await ctx.db
      .query("spaces")
      .withIndex("by_spaceName", (q) => q.eq("spaceName", args.spaceName))
      .first();

    if (existingSpace) {
      await ctx.db.patch(existingSpace._id, {
        isFull: args.isFull,
      });
    } else {
      await ctx.db.insert("spaces", {
        spaceName: args.spaceName,
        isFull: args.isFull,
      });
    }
  },
});

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lockedin_handeler-1.8.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lockedin_handeler-1.8.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file lockedin_handeler-1.8.0.tar.gz.

File metadata

  • Download URL: lockedin_handeler-1.8.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lockedin_handeler-1.8.0.tar.gz
Algorithm Hash digest
SHA256 5ae0371700c7a32b026079f635c0617ad2cb6afb331322495ed91a21a6a70c6c
MD5 a015f5cfb405a0703352678b94cdc918
BLAKE2b-256 31ec4fe50ad43e5e5144d99d6213013f988ef1b5925c7bf78f0b2d2313e6cc12

See more details on using hashes here.

File details

Details for the file lockedin_handeler-1.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lockedin_handeler-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f497c738d212146b8b371bda5863bd69b9ef9318cce9670590526ff98105fca
MD5 090f95ab8d445af8dae1df7d56ad0a31
BLAKE2b-256 fe63f822c98ba80bc39afba80567bbba4e2d26ce84b5cc83a949066d272f8d9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page