-
Notifications
You must be signed in to change notification settings - Fork 895
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
FR: Allow for class instance to be passed as data #311
Comments
Hello ! I found another solution instead of mapping the object. You can use |
thanks @BinsGuns , i tried this with the stringify and normaly it works, but where it not works is when a GeoPoint is inside the object... in this case the firebase.firestore.GeoPoint will be destroyed once it is in the database. |
@BinsGuns |
@comfortme I'm using https://github.com/kaiu-lab/ng-serializer to solve this pain, but still, having to create a clone of your object to be able to pass it for the data is unefficient as it could lead to performance issues with very large objects. |
@Supamiu |
For my solution I had an
|
I've just found another (pretty obvious) Solution on StackOverflow:
|
Does anyone know why this is prevented? In the code it is a very clear explicit check they do to see if the object has Object.prototype, so this isn't by accident. All the work arounds (while working) aren't really "nice". Like to be clear, would a PR be accepted that just removes this check? |
Yeah, that check was intentionally added for essentially 2 reasons:
That said, we were on the fence about being so strict about preventing custom objects, and we could potentially revisit this in the future and loosen the restriction. But I think we're inclined to keep it for now. |
Thanks. Simple solution. But it works. |
bad idea, you'll lose all Firestore stores dates as a special type. when you stringify it you're left with |
You can use |
[REQUIRED] Describe your environment
Describe the problem
When trying to add a document to a collection or to set it, the item has to be of type
object
, meaning that it can't be an instance of any class.The error is:
Steps to reproduce:
Simply run this in an angular 5.0.0 environment with angularfire2 5.0.0-rc.3:
I had to write this to make a temporary fix (on my top-level firestore data model class):
Then I replaced
add(item)
byadd(<Item>item.getData())
, which is kinda ugly but works like a charm.The text was updated successfully, but these errors were encountered: