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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lockedin_handeler-1.6.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.6.0.tar.gz
Algorithm Hash digest
SHA256 f047774f8e34404b781b37c068dee4416d7d5f6de9714b68e8816d486db7cf85
MD5 4295f4f7c644bd59b1c7cf64651d2196
BLAKE2b-256 3deeb79f8551bc99ba7d3883ba110894a01737a1fe0d84e0ad45b53c95164c0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lockedin_handeler-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c01d840141acf9c8195600a266e83c557c0f1ca414c77193a7de5b3e5192093
MD5 e4468789eab19f92147084329da681ca
BLAKE2b-256 999db37be15ddc5b9717dc0d18d54748224081c75f707ef8f456a4217c2a8670

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