Open claytonaalves opened 11 years ago
New version v0.2.0 supports events:
Firebird.attach(options, function(err, db) {
if (err)
throw err;
db.on('row', function(row, index, isObject) {
// index === Number
// isObject === is row object or array?
});
db.on('result', function(result) {
// result === Array
});
db.on('attach', function() {
});
db.on('detach', function(isPoolConnection) {
// isPoolConnection == Boolean
});
db.on('reconnect', function() {
});
db.on('error', function(err) {
});
db.on('transaction', function(isolation) {
// isolation === Number
});
db.on('commit', function() {
});
db.on('rollback', function() {
});
db.detach();
});
Thanks.
I think he asks for Firebird internal events http://www.janus-software.com/fbmanual/manual.php?book=php&topic=49 http://mikejustin.wordpress.com/2012/11/06/firebird-database-events-and-message-oriented-middleware/ One example from the C++ node driver http://www.king-foo.be/2011/07/catch-firebird-events-with-node-js/
Yes. That's what I meant.
This is definitely a much needed feature.
somebody works with firebird events ? in php has ibase_set_event_handler
+1
good news it's done you can try on https://github.com/sdnetwork/node-firebird
db.attachEvent( function (err, evtmgr) {
if (err)
return console.log('Error : ', err);
evtmgr.on('post_event', function (name, count) {
console.log("rec event", name, count);
})
evtmgr.registerEvent(["evt1", "evt2"], function (err) {
console.log('ready to receive evt1 and evt2')
})
evtmgr.unregisterEvent(["evt1"], function (err) {
console.log('remove evt1, after that you only receive evt2')
})
})
Working as expected. Good work.
@sdnetwork have limit for registerEvent ?
i dont't know why ?
Just a question!
Hello, I would try to use the post_event option in firebird but can't find the function attachEvent. Is she still available in the last version of node-firebird ?
@beletot Use the forked version from @sdnetwork ... @hgourvest hasn't merged the feature yet.
Hi, yours have problem with events lost attach and not but received post_event after long time?
Hello, could someone tell me please, if the listening to firebird's post events feature implemented.
Hi @sdnetwork, i'm use the node-firebird and the need to listen for events arises, when using flamerobin I see that the events are generated, but I cannot hear on the node. Is there any way to help me? Thank you very much. I'm Brazilian, sorry for my English
@slachtar @lukaas25 No but there are other nodejs libraries that give you that possibility
@slachtar thanks for the return, but I managed to monitor the events, this package helped a lot
@slachtar thanks for the return, but I managed to monitor the events, this package helped a lot
How do you do that? Using hgourvest package or sdnetwork?
@balenaultra I did like this: Firebird.attach(options, async function(err, db) {
if (err){
return console.log("error",err)
}else{
db.attachEvent( function (err, evtmgr) {
if (err)
return console.log('Error : ', err);
evtmgr.registerEvent(["even_name"], function (error) {
if(error){
return error;
}
})
evtmgr.on('event_name', async function(name,count){
console.log(name,count)
})
})
console.log(name,count)
which package? hgourvest or sdnetwork ?
@balenaultra sdnetwork package
@lukaas25 voce quer pegar um evento tipo uma trigger? conseguiu? tambem estou querendo e nao estou conseguindo
@lukaas25 voce quer pegar um evento tipo uma trigger? conseguiu? tambem estou querendo e nao estou conseguindo
Isso, eu estou visualizando os eventos do banco, consegui sim, pelo código acima esta funcionando, usa o pacote do sdnetwork que vais conseguir
This was already mentioned but let's make it clear.
hgourvest/node-firebird doesn't provide a way to capture events emitted through firebird's POST_EVENT
(https://www.firebirdsql.org/file/documentation/papers_presentations/Power_Firebird_events.pdf).
Although, a fork of this project was created by sdnetwork and it's available here: https://github.com/sdnetwork/node-firebird
The method that allows to list for events is not documented in the project's readme.md file but you can see the implementation here: https://github.com/sdnetwork/node-firebird/blob/master/lib/index.js#L1778
In order to use that method you must install the sdnetwork library.
Then, in order to import firebird you need to var Firebird = require('node-firebird-dev')
Then you will be able to use the implementation suggested by @lukaas25 above https://github.com/hgourvest/node-firebird/issues/28#issuecomment-830673752
Firebird.attach(options, async function(err, db) {
if (err) {
return console.log("error", err)
} else {
db.attachEvent(function(err, evtmgr) {
if (err)
return console.log('Error : ', err);
// Start listening for fb events here. In this case, this will fire if we call "POST_EVENT 'event_name'" from a trigger or from a stored procedure.
evtmgr.registerEvent(["event_name"], function(error) {
if (error) {
return error;
}
})
evtmgr.on('event_name', async function(name, count) {
console.log(name, count)
})
})
}
})
Note: sdnetwork is not receiving any updates for a while now.
Still think it would be a great add to the project if we could bring sdnetwork attachEvent feature to this project. Don't you agree?
@hgourvest @mariuz ?
I think he asks for Firebird internal events http://www.janus-software.com/fbmanual/manual.php?book=php&topic=49 http://mikejustin.wordpress.com/2012/11/06/firebird-database-events-and-message-oriented-middleware/ One example from the C++ node driver http://www.king-foo.be/2011/07/catch-firebird-events-with-node-js/
TypeError: db.registerEvent is not a function
@eduardochiletto as I said previously, you can't call registerEvent in node-firebird. You will have to install a fork (node-firebird-dev) created from this project to have such feature.
Is there a way to listen for Firebird events ?