0

it is my client-demo. I want to get all doc in the "file" collection. but i get null

enter image description here

I use the mongo shell to test it. I find the doc data exists enter image description here

I'm sure the client connects to server successfully. cause when i invoke connection.get('file','test'), console log is the same as mongo shell. log text (Delta { ops: [ { insert: 'Hi!12323232' } ] }) enter image description here

i expected that query.results is an array contains correct docs.

Kent Wood
  • 1,392
  • 2
  • 14
  • 30
  • Would it be easier to simply copy and paste your script, rather than taking a screenshot, uploading it, and then sharing the link to the image in this question? – Wahyu Kristianto Mar 17 '23 at 16:25

1 Answers1

0

I find the answer in the sharedb document I should add the ready event callback:

var query = connection.createFetchQuery('file', {}, null);

query.on('ready', () => {
    query.results.forEach((doc) => console.log(doc.data));
});
Tyler2P
  • 2,324
  • 26
  • 22
  • 31