I am attempting to get the key of a document using the Firestore resource property id derived from using get(), like so:
get(/databases/$(database)/documents/the/$(path)/is/$(request.resource.data.here)).id
I don't think id is available. I have tried a simulation using exists() without the id property at the end and it worked, so I know the resource is there and the path is correct.
Here is the piece of Firestore security rule doc I referenced: https://firebase.google.com/docs/reference/rules/rules.firestore.Resource
Not sure if the way I try to get the id is incorrect or it's just not available?
Related
I've my context in Orion within multiple attributes;
how can I also get the attributes' timestamp ("modDate") via GET query?
Thank you so much
According with Builtin Attributes documentation (to which dateModified belongs):
Builtin attributes are not rendered by default. In order to render a specific attribute, add its name to the attrs parameter in URLs (or payload field in POST /v2/op/query operation) or subscription (attrs sub-field within notification).
So, in the case of GET, you have to use something like this:
GET /v2/entities?attrs=*,dateModified
The * is needed to include all the regular attributes. If you ommit it and use just ?attrs=dateModified you will get only dateModified and no other attribute.
EDIT: in the case you want to get not the entity dateModified attribute but the attribute dateModified metadata is similar. In this case, from Builtin Metadata documentation
Builtin metadata are not rendered by default. In order to render a specific metadata, add its name to the metadata URL parameter (or payload field in POST /v2/op/query operation) or subscription (metadata sub-field within notification).
So:
GET /v2/entities?metadata=*,dateModified
I have an object entity in which i store many fields including clientNumber and clientName .
I know that i can use property query on the clientNumber field but i wouldn't get the clientName,
i also know that in objectbox for java there is a filter method that might solve my problem,
but appart from retrieving all the clients and filtering data manually i don't know any other way to do it with flutter .
Could you tell me if there is a more elegant way to achieve the same result ?
Thank you by advance for your answer, and for the great product that is objectbox
You want to have a look at regular queries (not property queries). I imagine it could look like something like this:
Query<Client> query = box.query(client_.clientName.equals('Joe')).build();
List<Client> joes = query.find();
Now, having a the entire object(s), you can easily access any property.
I'm planning to use mobgodb as my backend storage and graphql + relay for the client-server communication.
How can I reconcile Relay's globalId and Mongo id? Should they even be the same, if not how can I connect one to another?
I think there are two options:
Use mongoose and set the id option to true on your models, it will generate an id attribute with the hex string
or on your graphql schemas add an id field and resolve it this way (not tested)
resolve(me) {
return me._id.toString()
}
globalIdField is usually used to define the id field for the graphql entity and internally it uses toGlobalId function which accepts the id as the 2nd argument. fromGlobalId function could then be used in the node interface definition to extract both id and the defined type.
Here is a mongodb example of how to define the id field, and then use it.
When I query the metadata using RetrieveMetadataChangesRequest, the RetrieveMetadataChangesResponse returns EntityMetadata and DeletedMetadata. The DeletedMetadata only returns the MetadataId.
Is there a way to get the metadata for the attribute without knowing the entity? Even just the attribute name would be fine.
RetrieveAttributeRequest I think only works if the attribute exists and if you have the entitylogicalname.
No, the only infomration available is the MetadataId.
Quoting from the SDK:
This collection is a dictionary of GUID values using a
DeletedMetadataFilters as a key. The GUID values represent MetadataId
values of the metadata items.
Looking at another part of the SDK specifically addresses this question:
You will also use DeletedMetadataFilters enumeration as a key to the
RetrieveMetadataChangesResponse.DeletedMetadata to filter the GUID
values found in the RetrieveMetadataChangesResponse.DeletedMetadata
property. When you design a metadata cache you will want to use the
MetadataId for each item so that you can identify deleted metadata
items and remove them.
So as a developer you are expected to populate a cache of metadata of interest to your application. You can query the CRM Metadata to find changes and deletes - but in the case of a delete you are responsible for having collected the metadata in your cache.
I've made a guestbook application using Google App Engine(GAE):python and the client is running on iPhone.
It has ability to write messages on the board with nickname.
The entity has 3 fileds:
nickname
date
message
And I'm about to make another feature that user can post reply(or comment) on a message.
But to do this, I think there should a 'primary key' to the guestbook entity, so I can put some information about the reply on a message.
With that three fields, I can't get just one message out of database.
I'm a newbie to database. Does database save some kind of index automatically? or is it has to be done by user?
And if it's done automatically by database itself(or not), how can I get just one entity with the key??
And I want to get some advise about how to make reply feature generally also. Thanks to read.
Every entity has a key. If you don't assign a key_name when you create the entity, part of the key is an automatically-assigned numeric ID. Properties other than long text fields are automatically indexed unless you specify otherwise.
To get an entity if you know the key, you simply do db.get(key). For the replies, you probably want to use a db.ReferenceProperty in the reply entity to point to the parent message; this will automatically create a backreference query in the message to get replies.
Each entity has a key, it contains information such as the kind of entity it is, it's namespace, parent entities, and the most importantly a unique identifier (optionally user specifiable).
You can get the key of an entity using the key method that all entities have.
message.key()
A key can be converted to and from a URL-safe string.
message_key = str(message.key())
message = Message.get(message_key)
If the key has a user-specified unique identifier (key name), you can access it like this
message.key().name()
Alternatively, if a key name was not specified, an id will be automatically assigned.
message.key().id()
To assign a key name to an entity, you must specify it when creating the entity, you are not able to add/remove or change the key name afterwards.
message = Message(key_name='someusefulstring', content='etc')
message.put()
You will then be able to fetch the message from the datastore using the key name
message = Message.get_by_key_name('someusefulstring')
Use the db.ReferenceProperty to store a reference to another entity (can be of any kind)
It's a good idea to use key name whenever possible, as fetching from the datastore is much faster using them, as it doesn't involve querying.