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.7.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.7.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lockedin_handeler-1.7.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.7.0.tar.gz
Algorithm Hash digest
SHA256 ae05e79b48e910214c9ec381781f9562413c4ec2337cedbdee58dd45e0250c18
MD5 021ff684c5794177cea04110f94f6605
BLAKE2b-256 1bdce7fecf9dd809507eadd859d9d0c8db01bf98741b90b8b4eae04cf7846d7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lockedin_handeler-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b25c443e5abdf17c5996ad8de630e2ff74b6b902ca7148ddd21106bdff0d3755
MD5 37a2b4a3ef884e658a99c9b1cc9a4ac3
BLAKE2b-256 7649c0bf14d3c237a440f3d59c2979f2e414ab812ab53ec51a657b8b06c02f70

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