Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
POD
Commits
7fe28e0c
Verified
Commit
7fe28e0c
authored
5 years ago
by
Vasili Novikov
Browse files
Options
Download
Email Patches
Plain Diff
use millisecond precision instead of nanosecond
parent
59271ec7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/database_init.rs
+1
-1
src/database_init.rs
src/internal_api.rs
+5
-5
src/internal_api.rs
with
6 additions
and
6 deletions
+6
-6
src/database_init.rs
+
1
-
1
View file @
7fe28e0c
...
...
@@ -54,7 +54,7 @@ enum DatabaseColumnType {
/// to the clients, however, and clients should only ever receive/send `true` and `false`.
Bool
,
/// The number of non-leap-
nano
seconds since January 1, 1970 UTC.
/// The number of non-leap-
milli
seconds since January 1, 1970 UTC.
/// Use this database type to denote DateTime.
/// Internally stored as Integer and should be passed as Integer.
DateTime
,
...
...
This diff is collapsed.
Click to expand it.
src/internal_api.rs
+
5
-
5
View file @
7fe28e0c
...
...
@@ -72,7 +72,7 @@ pub fn create_item(sqlite: &Pool<SqliteConnectionManager>, json: Value) -> Resul
}
};
let
time_now
=
Utc
::
now
()
.timestamp_
nano
s
();
let
time_now
=
Utc
::
now
()
.timestamp_
milli
s
();
fields_map
.insert
(
"dateCreated"
.to_string
(),
time_now
.into
());
fields_map
.insert
(
"dateModified"
.to_string
(),
time_now
.into
());
fields_map
.insert
(
"version"
.to_string
(),
Value
::
from
(
1
));
...
...
@@ -148,7 +148,7 @@ fn create_item_tx(tx: &Transaction, fields: HashMap<String, Value>) -> Result<()
.into_iter
()
.filter
(|(
k
,
v
)|
!
is_array_or_object
(
v
)
&&
validate_field_name
(
k
)
.is_ok
())
.collect
();
let
time_now
=
Utc
::
now
()
.timestamp_
nano
s
();
let
time_now
=
Utc
::
now
()
.timestamp_
milli
s
();
fields
.insert
(
"dateCreated"
.to_string
(),
time_now
.into
());
fields
.insert
(
"dateModified"
.to_string
(),
time_now
.into
());
fields
.insert
(
"version"
.to_string
(),
Value
::
from
(
1
));
...
...
@@ -168,7 +168,7 @@ fn update_item_tx(tx: &Transaction, fields: HashMap<String, Value>) -> Result<()
.into_iter
()
.filter
(|(
k
,
v
)|
!
is_array_or_object
(
v
)
&&
validate_field_name
(
k
)
.is_ok
())
.collect
();
let
time_now
=
Utc
::
now
()
.timestamp_
nano
s
();
let
time_now
=
Utc
::
now
()
.timestamp_
milli
s
();
fields
.remove
(
"_type"
);
fields
.remove
(
"dateCreated"
);
fields
.insert
(
"dateModified"
.to_string
(),
time_now
.into
());
...
...
@@ -263,7 +263,7 @@ pub fn update_item(sqlite: &Pool<SqliteConnectionManager>, uid: i64, json: Value
fields_map
.remove
(
"dateModified"
);
fields_map
.remove
(
"version"
);
let
time_now
=
Utc
::
now
()
.timestamp_
nano
s
();
let
time_now
=
Utc
::
now
()
.timestamp_
milli
s
();
fields_map
.insert
(
"dateModified"
.to_string
(),
time_now
.into
());
let
mut
sql_body
=
"UPDATE items SET "
.to_string
();
...
...
@@ -309,7 +309,7 @@ pub fn update_item(sqlite: &Pool<SqliteConnectionManager>, uid: i64, json: Value
/// Return NOT_FOUND if item does not exist.
pub
fn
delete_item
(
sqlite
:
&
Pool
<
SqliteConnectionManager
>
,
uid
:
i64
)
->
Result
<
()
>
{
debug!
(
"Deleting item {}"
,
uid
);
let
time_now
=
Utc
::
now
()
.timestamp_
nano
s
();
let
time_now
=
Utc
::
now
()
.timestamp_
milli
s
();
let
json
=
serde_json
::
json!
({
"deleted"
:
true
,
"dateModified"
:
time_now
,
});
update_item
(
sqlite
,
uid
,
json
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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