Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jxpsert/nodequent
Laravel's Eloquent in Node
https://github.com/jxpsert/nodequent
eloquent javascript laravel node nodejs
Last synced: 24 days ago
JSON representation
Laravel's Eloquent in Node
- Host: GitHub
- URL: https://github.com/jxpsert/nodequent
- Owner: jxpsert
- License: gpl-3.0
- Created: 2024-04-25T06:37:52.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-04-25T10:18:15.000Z (8 months ago)
- Last Synced: 2024-04-26T06:50:31.275Z (8 months ago)
- Topics: eloquent, javascript, laravel, node, nodejs
- Language: TypeScript
- Homepage: https://jxpsert.github.io/nodequent/
- Size: 138 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
- Security: SECURITY.md
Awesome Lists containing this project
README
# nodequent
[![GitHub version](https://badge.fury.io/gh/jxpsert%2Fnodequent.svg)](https://badge.fury.io/gh/jxpsert%2Fnodequent) [![npm version](https://badge.fury.io/js/nodequent.svg)](https://badge.fury.io/js/nodequent)
Use Laravel's Eloquent functionality from the comfort of your own Node.js environment.
## Installation
``npm install --save nodequent``
## Usage
```JS
// index.js
require('nodequent').init();
const { User } = require('./models/User');(async () => {
let users = await User.all();
console.log(users);
})();// models/User.js
const { Model } = require('nodequent');class User extends Model {
table = 'users';
fillable = ['name', 'email', 'password'];
softDeletes = true;
}module.exports = { User };
```
```bash
Collection(2) [
User {
primaryKey: 'id',
keyType: 'int',
fillable: [ 'name', 'email', 'password' ],
incrementing: true,
softDeletes: true,
attributes: {
id: 1,
name: 'Jane Doe',
email: '[email protected]',
password: null,
created_at: '2024-04-23 14:37:40',
updated_at: '2024-04-23 14:37:40'
},
table: 'users'
},
User {
primaryKey: 'id',
keyType: 'int',
fillable: [ 'name', 'email', 'password' ],
incrementing: true,
softDeletes: true,
attributes: {
id: 2,
name: 'John Doe',
email: '[email protected]',
password: null,
created_at: '2024-04-23 14:37:39',
updated_at: '2024-04-23 14:37:39'
},
table: 'users'
}
]
```### Database without .env
```JS
require('nodequent').init({
database: {
host: 'localhost',
database: 'nodequent',
user: 'nodequent-user',
password: 'password123',
}
});
```## Contributing
Contributions are always appreciated in the form of pull requests.