bpmnServer / bpmn-server

BPMN 2.0 server for Node.js , providing modeling, execution, persistence and monitoring for Workflow. along with sample UI. Intended to be developers workbench for BPMN 2.0
MIT License
186 stars 48 forks source link

Query projection #221

Closed MaheshkumarSundaram closed 3 months ago

MaheshkumarSundaram commented 3 months ago

Hi @ralphhanna,

Query projection doesn't seem to work. I am pretty sure this was working.

I did double check the versions and I am updated. Could you please check whether this is a regression?

I used bpmn-client to test (added a case in cli.ts):

async function displayInstanceProjection(instanceId = null) {
  if (instanceId == null)
    instanceId = await question("Please provide your Instance ID: ");

  const project = await getCriteria("provide projection criteria");

  let insts = await server.datastore.findInstances({ id: instanceId }, project);

  for (var i = 0; i < insts.length; i++) {
    let inst = insts[i];
    console.log(JSON.stringify(inst));
  }
}

I get the full instance record instead the fields of projection. Am I missing something? Thanks.

ralphhanna commented 3 months ago

Sorry, since sort was added as another option name the syntax change slightly.

let insts = await server.dataStore.findInstances({id:"6dc47eb8-01a3-4213-b400-c8e18ffd45c2" }, { projection: {id:1, name:1}});
MaheshkumarSundaram commented 3 months ago

Thanks for the clarification @ralphhanna. It works.

Curious about sort option now. Is it just simply sorting the order of retrieved fields?

ralphhanna commented 3 months ago

Yes, it passes the sort to Mongo