2020-02-19 18:50:51 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using LeanCloud.Storage.Internal.Codec;
|
|
|
|
|
|
|
|
|
|
namespace LeanCloud.Storage.Internal.Query {
|
2020-03-17 11:41:38 +08:00
|
|
|
|
public class LCRelatedCondition : ILCQueryCondition {
|
2020-02-19 18:50:51 +08:00
|
|
|
|
readonly LCObject parent;
|
|
|
|
|
readonly string key;
|
|
|
|
|
|
2020-03-17 11:41:38 +08:00
|
|
|
|
public LCRelatedCondition(LCObject parent, string key) {
|
2020-02-19 18:50:51 +08:00
|
|
|
|
this.parent = parent;
|
|
|
|
|
this.key = key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Equals(ILCQueryCondition other) {
|
|
|
|
|
if (other is LCRelatedCondition cond) {
|
|
|
|
|
return cond.key == key;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, object> Encode() {
|
|
|
|
|
return new Dictionary<string, object> {
|
|
|
|
|
{ "$relatedTo", new Dictionary<string, object> {
|
|
|
|
|
{ "object", LCEncoder.Encode(parent) },
|
|
|
|
|
{ "key", key }
|
|
|
|
|
} }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|