Skip to content
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

Attribute to specify the Key (ID) #320

Open
sact1909 opened this issue May 9, 2024 · 3 comments
Open

Attribute to specify the Key (ID) #320

sact1909 opened this issue May 9, 2024 · 3 comments

Comments

@sact1909
Copy link

sact1909 commented May 9, 2024

Create an attribute that allows the user to specify the Key property to use as ID when post a new object in case someone wants to use his datatype key structure as Guid, AutoEnum etc...

Example
Model Class

public class TodoItem
{
    [FirebaseKey]
    public Guid ID {get;set;}
    public string Title { get; set; }
}

await firebaseClient.Child("Todo").PostAsync(new TodoItem
{
    ID = Guid.NewGuid(),
    Title = "This is a Text"
});

Result in Firebase RealTiem Database

"Todo":{
    "621e7bf1-1d39-493f-a6b1-537afb5efa41":{
      "Title":"This is a Text"
    }
}
@sact1909
Copy link
Author

sact1909 commented May 9, 2024

I guess I could work on this if you allow me to do it

@sact1909
Copy link
Author

sact1909 commented Jul 6, 2024

Hey man, did you find a way to specify the key using this library?
Or you had to adjust it with the attribute you mentioned?

@bnbgames both, hahahhahah I'm pending to send a pull request to add this feature zoom, but there is also way to do it with the library but is a little bit scary the way can do this....

@bnbgames
Copy link

bnbgames commented Jul 6, 2024

I just used PutAsync instead of PostAsync.
That way there's no auto-generated key.

Now looking for a way to do a field increment with mutable transaction, to assure data integrity.
Know of a way to do that maybe? haha

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants