Closed kklan closed 6 years ago
1) What I would do is that instead of having a friends
list for the AppUser
itself, I would have a Relationships
collection or shared collection and I would have firstUserId
, secondUserId
and an Enum RelationshipType
which would represent the relationship between to users. Then you can just query the friends when needed based on the userIds.
2) There are two ways you can do that.
Guid.NewGuid().ToString
method on the newUser
.AddAsync
which contains an Entity
property. This property will have the Id
set to the one generated for this object.Thanks, can you provide a sample Model.cs example?.
[CosmosCollection("Relationships")]
public class Relation
{
[JsonProperty(PropertyName = "firstId")]
public string firstUserId { get; set; }
[JsonProperty(PropertyName = "secondId")]
public string secondUserId { get; set; }
public enum RelationShipStatus { Friends, NotFriends };
}
var query = await _cosmosStore.QueryMultipleAsync()
but it is not found. There is only Query()
available. Is there anyway I can use direct SQL syntax to insert data? select
via SQLGot it.
Just for my knowledge, If I were to follow my previous idea of inserting data into a specific field, for example: insert data into C where userId = "ABC". How would I do that?
Also I really appreciate all the the help.
Assuming you mean adding to the Friends
list object that you had.
CosmosDB does not support partial document updates yet. That means that you would have query for the user where userId = "ABC" with LINQ, update the object and then use the UpdateAsync
method to update the whole document.
You're welcome. A start at the repo is highly appreciated 😄
Oh I see. Thank you.
Hi,
Sorry to bother you again. I'm very new to this.
I'm trying to inset data into my cosmosdb collection called AppUsers. Basically for my social net app, a person is able to add friend using userId and friendsUserId. So I want to insert into collection (friendUserId in Friends) where
userId="AXYZ963"
. I'm not able to figure out how to do that using cosmonaut and Linq.Here is my collection:
await _cosmosStore.AddAsync(newUser);
can it returnid
as well?Thanks KL