open-index/open-npm huggingface dataset:
npm package: @pikmeup/database-service
Description: Shared database service for PikMeUp using Typegoose with MongoDB
Author: PikMeUp Team
Latest version: 1.2.6

# @pikmeup/database-service

A shared database service for PikMeUp microservices using Typegoose with MongoDB.

## Installation

```bash
npm install @pikmeup/database-service
```

## Usage

### Basic Setup

```typescript
import { connectToDatabase, disconnectFromDatabase, models } from '@pikmeup/database-service';

// Connect to MongoDB
await connectToDatabase('mongodb://localhost:27017/your-database');

// Use models
const user = await models.User.create({
  name: 'John Doe',
  email: 'john@example.com',
  password: 'securepassword',
  role: 'employee'
});

// Disconnect when done
await disconnectFromDatabase();
```

### Available Models

- `User` - User management
- `Driver` - Driver information
- `Cab` - Cab details
- `Route` - Route information
- `Trip` - Trip records

### Example: Creating a Driver with User

```typescript
import { models, Role } from '@pikmeup/database-service';

// First create a user
const user = await models.User.create({
  name: 'Driver Name',
  email: 'driver@example.com',
  password: 'securepassword',
  role: Role.DRIVER
});

// Then create the driver profile
const driver = await models.Driver.create({
  name: 'Driver Name',
  email: 'driver@example.com',
  phone: '1234567890',
  licenseNumber: 'DL123456',
  status: 'AVAILABLE',
  userId: user._id
});
```

### Example: Creating a Cab with Driver

```typescript
const cab = await models.Cab.create({
  number: 'KA01AB1234',
  capacity: 4,
  driver: driver._id
});
```

## Configuration

The package uses Typegoose with MongoDB. Make sure your MongoDB instance is running and accessible.

## Development

```bash
# Install dependencies
npm install

# Run tests
npm test

# Build the package
npm run build
```

## License

MIT