burawi / tayr Goto Github PK
View Code? Open in Web Editor NEWan easy on-the-fly ORM for NodeJS, inspired by RedBeanPHP
Home Page: http://burawi.github.io/tayr/
License: MIT License
an easy on-the-fly ORM for NodeJS, inspired by RedBeanPHP
Home Page: http://burawi.github.io/tayr/
License: MIT License
hi,
I really like redbeanphp, and finding your library made me excited, however before I can use it, I see a few problems.
first one is I don't see any way to handle errors. The most basic example being:
var nest = require('Tayr');
var T = new nest({
host: 'localhost',
database: 'databaseName'
});
if there is no MySQL server running on localhost, connection.connect();
will get ECONNREFUSED
, however, there is no callback given to it, to get the error and reject the promise.
sequelize for example lets you handle connections errors this way:
sequelize
.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});
maybe we can expose the createDb
function instead of executing it automatically, and allow the user to catch connection errors that way ?
var nest = require('Tayr');
var T = new nest({
host: 'localhost',
database: 'databaseName'
}); // createDb is not called automatically, so no exception is raised
T.createDb().then(()=>{
// database is ready
}).catch((err)=>{
//err can be ECONNREFUSED
})
another example is on line 497, if (err) throw err;
will either crash the node process or keep the promise in pending state indefinitely.
Instead, something like if (err) return reject(err);
would be more appropriate. The goal here is to allow catching and handling of errors in user code.
I also think that the onReject
method is not very helpful, instead, I would prefer if errors would be handlable using a .catch
in user code.
@burawi, is this project still under maintenance or abandoned ?
i want to contribute here !
make package.json better
pre-release preparation ( not publish )
Let me just say, I love this module! That being said, I'm having a hard time tracking down why the code below doesn't create a 'BIGINT' field for 'dateCreated'
let userGroup = new T.tayr('userGroup', {
dateCreated: new Date()
})
let user = new T.tayr('user', {
firstName: 'Default',
lastName: 'User'
})
user.setParent(userGroup, function () {
console.log('User: ' + user.id + ' belongs to group: ' + userGroup.id)
})
userGroup.store(function () {
user.store(function () {
console.log('stored:' + userGroup + ' and: ' + user)
})
})
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.