public static async ETTask <T> Create <T>(this CacheProxyComponent self, T entity) where T : ComponentWithId { Session session = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress); CacheQueryResponse cacheCreateResponse = (CacheQueryResponse)await session.Call(new CacheCreateRequest { CollectionName = typeof(T).Name.ToLower(), Component = entity, }); return((T)cacheCreateResponse.Component); }
public static async ETTask <T> UpdateById <T>(this CacheProxyComponent self, long id, string updatedData) where T : ComponentWithId { Session session = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress); CacheQueryResponse cacheUpdateByIdResponse = (CacheQueryResponse)await session.Call(new CacheUpdateByIdRequest { CollectionName = typeof(T).Name.ToLower(), Id = id, DataJson = updatedData, }); return((T)cacheUpdateByIdResponse.Component); }
public static async ETTask <T> QueryById <T>(this CacheProxyComponent self, string collectionName, long id, List <string> fields = null) where T : ComponentWithId { Session session = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress); CacheQueryResponse cacheQueryByIdResponse = (CacheQueryResponse)await session.Call(new CacheQueryByIdRequest { CollectionName = collectionName, Id = id, Fields = fields, }); return((T)cacheQueryByIdResponse.Component); }
public static async ETTask <T> QueryByUnique <T>(this CacheProxyComponent self, string uniqueName, BsonDocument condition) where T : ComponentWithId { Session session = Game.Scene.GetComponent <NetInnerComponent>().Get(self.dbAddress); CacheQueryResponse cacheQueryByUniqueResponse = (CacheQueryResponse)await session.Call(new CacheQueryByUniqueRequest { CollectionName = typeof(T).Name.ToLower(), Json = condition.ToJson(), UniqueName = uniqueName, }); return((T)cacheQueryByUniqueResponse.Component); }