New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Postgresql's date and bytea column type? #355

Closed
Matrix-Zhang opened this Issue Jun 15, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@Matrix-Zhang

Matrix-Zhang commented Jun 15, 2016

follow the started-guide, i want to add a post create date column with date type and a picture with bytea type, but i don't know how to do this, any sample please... 3ks

@Matrix-Zhang Matrix-Zhang changed the title from How to use Postgresql's date bytea column type? to How to use Postgresql's date and bytea column type? Jun 15, 2016

@Matrix-Zhang

This comment has been minimized.

Matrix-Zhang commented Jun 23, 2016

any one can help me? right now, i can quey the record with the PgTimestamp type,

#[derive(Queryable, Debug, Clone)]
pub struct DevicePeriod {
    pub id: i32,
    pub device_id: i32,
    pub date_time: PgTimestamp,
    pub confirmed: bool
}

but how to write the insertable ?

#[insertable_into(device_period)]
pub struct NewDevicePeriod<'a> {
    pub device_id: i32,
    pub date_time: NaiveDateTime //here, will build error, change to PgTimestamp is ok, but the chrono timestamp is since 1970
}
@Matrix-Zhang

This comment has been minimized.

Matrix-Zhang commented Jun 23, 2016

i found the pg types sources have to_sql for NaiveDateTime, but i don't know how to use it

@sgrif

This comment has been minimized.

Member

sgrif commented Jun 27, 2016

Hey sorry for the delay in responding. You need to enable the chrono feature to deal with dates. PG date will map to chrono::NaiveDate. bytea maps to Vec<u8>, but you may need to point at master if you're using the infer_schema! macro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment