Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
f384e879
Commit
f384e879
authored
Dec 12, 2009
by
Eric Fredricksen
Committed by
Eric Fredricksen
Dec 12, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emit events on commit, rollback, update. Not tested though.
parent
779ee011
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
sqlite3_bindings.cc
sqlite3_bindings.cc
+35
-0
No files found.
sqlite3_bindings.cc
View file @
f384e879
...
...
@@ -116,6 +116,9 @@ protected:
String::New("Argument " #I " must be an integer"))); \
}
//
// JS DatabaseSync bindings
//
static
Handle
<
Value
>
Changes
(
const
Arguments
&
args
)
{
HandleScope
scope
;
...
...
@@ -139,12 +142,40 @@ protected:
return
scope
.
Close
(
result
);
}
static
int
CommitHook
(
void
*
v_this
)
{
HandleScope
scope
;
Sqlite3Db
*
db
=
static_cast
<
Sqlite3Db
*>
(
v_this
);
db
->
Emit
(
"commit"
,
0
,
NULL
);
// TODO: allow change in return value to convert to rollback...somehow
return
0
;
}
static
void
RollbackHook
(
void
*
v_this
)
{
HandleScope
scope
;
Sqlite3Db
*
db
=
static_cast
<
Sqlite3Db
*>
(
v_this
);
db
->
Emit
(
"rollback"
,
0
,
NULL
);
}
static
void
UpdateHook
(
void
*
v_this
,
int
operation
,
const
char
*
database
,
const
char
*
table
,
sqlite_int64
rowid
)
{
HandleScope
scope
;
Sqlite3Db
*
db
=
static_cast
<
Sqlite3Db
*>
(
v_this
);
Local
<
Value
>
args
[]
=
{
Int32
::
New
(
operation
),
String
::
New
(
database
),
String
::
New
(
table
),
Number
::
New
(
rowid
)
};
db
->
Emit
(
"update"
,
4
,
args
);
}
static
Handle
<
Value
>
Open
(
const
Arguments
&
args
)
{
HandleScope
scope
;
Sqlite3Db
*
db
=
ObjectWrap
::
Unwrap
<
Sqlite3Db
>
(
args
.
This
());
REQ_STR_ARG
(
0
,
filename
);
Close
(
args
);
// ignores args anyway, except This
CHECK
(
sqlite3_open
(
*
filename
,
&
db
->
db_
));
sqlite3_commit_hook
(
*
db
,
CommitHook
,
db
);
sqlite3_rollback_hook
(
*
db
,
RollbackHook
,
db
);
sqlite3_update_hook
(
*
db
,
UpdateHook
,
db
);
return
args
.
This
();
}
...
...
@@ -204,6 +235,10 @@ protected:
operator
sqlite3_stmt
*
()
const
{
return
stmt_
;
}
//
// JS Bindings
//
static
Handle
<
Value
>
Bind
(
const
Arguments
&
args
)
{
HandleScope
scope
;
Statement
*
stmt
=
ObjectWrap
::
Unwrap
<
Statement
>
(
args
.
This
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment