PyxisDB
PyxisDB is a real-time database package for communicating with Pyxiscloud server. It provides a simple and efficient way to interact with your database using WebSocket connections.
Installation
To install PyxisDB, use npm:
npm install pyxisdb
Usage
Here's a basic example of how to use PyxisDB:
const pyx = require('pyxisdb');
pyx.connect('wss://your-pyxiscloud-server.com')
.then(() => {
console.log('Connected to PyxisCloud');
const userSchema = pyx.schema({
name: { type: 'string', required: true },
age: { type: 'number' },
email: { type: 'string', required: true }
}, 'users');
const User = pyx.model('users', userSchema);
User.insert({
name: 'John Doe',
age: 30,
email: 'john@example.com'
})
.then(result => console.log('Inserted:', result))
.catch(error => console.error('Insert error:', error));
User.find({ age: { $gte: 18 } })
.then(users => console.log('Adult users:', users))
.catch(error => console.error('Find error:', error));
})
.catch(error => console.error('Connection error:', error));
Features
- Real-time database operations
- Schema validation
- Automatic reconnection
- Support for insert, find, update, and delete operations
- Count and exists queries
API Reference
pyx.connect(url)
Connects to the Pyxiscloud server.
pyx.schema(schemaDefinition, collectionName)
Defines a schema for a collection.
pyx.model(collectionName, schema)
Creates a model based on a schema.
Model Methods
insert(document)
: Inserts a new documentfind(query)
: Finds documents matching the queryupdate(query, updateFields)
: Updates documents matching the querydelete(query)
: Deletes documents matching the querycount(query)
: Counts documents matching the queryexists(field, value)
: Checks if a document with the given field-value pair exists
License
This project is licensed under the MIT License.