return true;
}
+static bson* _qfgetupdateobj(const EJQF *qf) {
+ assert(qf->updateobj);
+ if (!qf->$ufields || TCLISTNUM(qf->$ufields) < 1) { //we do not ref $(query) fields.
+ return qf->updateobj;
+ }
+ const EJQ *q = qf->q;
+ bson *ret = bson_create();
+ bson_init(ret);
+ for (int i = 0; i < TCLISTNUM(qf->$ufields); ++i) {
+ const char *uf = TCLISTVALPTR(qf->$ufields, i);
+ for (int j = 0; *(q->allqfields + j) != '\0'; ++j) {
+ const EJQF *kqf = *(q->allqfields + j);
+ if (kqf == qf || kqf->$uslots == NULL || TCLISTNUM(kqf->$uslots) < 1) {
+ continue;
+ }
+ for (int k = 0; k < TCLISTNUM(kqf->$uslots); ++k) {
+ USLOT *uslot = TCLISTVALPTR(kqf->$uslots, k);
+ if (uslot->op == uf) {
+
+ //todo
+
+ break;
+ }
+ }
+ }
+ }
+ bson_finish(ret);
+ return ret;
+}
+
static bool _qryupdate(_QRYCTX *ctx, void *bsbuf, int bsbufsz) {
assert(ctx && ctx->q && (ctx->q->flags & EJQUPDATING) && bsbuf && ctx->didxctx);
}
}
}
+
+
if (setqf) { //$set
update = true;
bson_init_size(&bsout, bsbufsz);
kqf->$uslots = tclistnew2(TCLISTINYNUM);
}
USLOT uslot = {
- .mpos = 0,
+ .mpos = -1,
.dpos = (pptr - ukey),
- .op = &qf
+ .op = ukey
};
tclistpush(kqf->$uslots, &uslot, sizeof(uslot));
}
typedef struct { /**> $(query) matchin slot used in update $ placeholder processing. #91 */
int32_t mpos; /**> array position of matched element */
int32_t dpos; /**> $ position in the fieldpath */
- void *op; /**> Opaque pointer associated with slot */
+ const void *op; /**> Opaque pointer associated with slot */
} USLOT;
struct EJQF { /**> Matching field and status */