-
Notifications
You must be signed in to change notification settings - Fork 26
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
Get remote db model based on local model #49
Comments
You mean something like this? var supabotMessages = await client.Table<Message>().Filter("id", Postgrest.Constants.Operator.Equals, id).Get(); |
Well sort of yeah. Just without the verbosity of [Table("my_model")]
public class MyModel: BaseModel
{
[PrimaryKey("id_2")]
public string Id1 { get; set; }
[PrimaryKey("id_2")]
public string Id2{ get; set; }
[PrimaryKey("id_3")]
public string Id3 { get; set; }
[Column("my_col")]
public short MyCol{ get; set; }
//....
} would result in a query like: var filters = new Dictionary<string, string>()
{
{"id_1", localModel.Id1 },
{"id_2", localModel.Id2 },
{"id_3", localModel.Id3 },
};
var dbModel = postgrestClient.Table<MyModel>().Match(filters).Get(); where to me it feels like the dict creation part should be able to be created automatically based on the Hope that makes sense :D |
…del.PrimaryKeyColumn` in favor of a `PrimaryKey` dictionary with support for composite keys. - Added `Match(T model)` in reference to #49
Oh yes! Very nice. I've added the following on the var moviePerson = new MoviePerson { Id = 1, MovieId = 1, PersonId = 1 };
var findMoviePerson = await client.Table<MoviePerson>().Match(moviePerson).Single(); Is that better? (This tangentially required better supporting composite primary keys, which is appreciated!) |
If that works I’ll push it into the next version for you! |
Awesome, yeah the syntax looks very nice, thank you👌 |
Available in v2.1.0! |
Feature request
I'm not sure this is already possible (easily) and there's no discussions tab for this repo sadly so I figured I'd open an issue.
Basically I'm looking for a way to get the Model that's stored in postgres based on a model that already exists (read from local json or whatever). There's PrimaryKey annotations which I thought would be used for this sort of usecase but can't figure out how.
Describe the solution you'd like
something along those lines would be nice
The text was updated successfully, but these errors were encountered: