outlet-orm 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +20 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -157,6 +157,10 @@ const { DatabaseConnection, Model } = require('outlet-orm');
157
157
  ```javascript
158
158
  const { Model } = require('outlet-orm');
159
159
 
160
+ // Définition des modèles liés (voir Relations)
161
+ class Post extends Model { static table = 'posts'; }
162
+ class Profile extends Model { static table = 'profiles'; }
163
+
160
164
  class User extends Model {
161
165
  static table = 'users';
162
166
  static primaryKey = 'id'; // Par défaut: 'id'
@@ -349,7 +353,11 @@ const withCounts = await User.withCount('posts').get();
349
353
  ```javascript
350
354
  const { Model } = require('outlet-orm');
351
355
 
356
+ class Profile extends Model { static table = 'profiles'; }
357
+
352
358
  class User extends Model {
359
+ static table = 'users';
360
+
353
361
  profile() {
354
362
  return this.hasOne(Profile, 'user_id');
355
363
  }
@@ -364,7 +372,11 @@ const profile = await user.profile().get();
364
372
  ```javascript
365
373
  const { Model } = require('outlet-orm');
366
374
 
375
+ class Post extends Model { static table = 'posts'; }
376
+
367
377
  class User extends Model {
378
+ static table = 'users';
379
+
368
380
  posts() {
369
381
  return this.hasMany(Post, 'user_id');
370
382
  }
@@ -379,7 +391,11 @@ const posts = await user.posts().get();
379
391
  ```javascript
380
392
  const { Model } = require('outlet-orm');
381
393
 
394
+ class User extends Model { static table = 'users'; }
395
+
382
396
  class Post extends Model {
397
+ static table = 'posts';
398
+
383
399
  author() {
384
400
  return this.belongsTo(User, 'user_id');
385
401
  }
@@ -394,7 +410,11 @@ const author = await post.author().get();
394
410
  ```javascript
395
411
  const { Model } = require('outlet-orm');
396
412
 
413
+ class Role extends Model { static table = 'roles'; }
414
+
397
415
  class User extends Model {
416
+ static table = 'users';
417
+
398
418
  roles() {
399
419
  return this.belongsToMany(
400
420
  Role,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "outlet-orm",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "A Laravel Eloquent-inspired ORM for Node.js with support for MySQL, PostgreSQL, and SQLite",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",