Reputation: 1
it is my client-demo. I want to get all doc in the "file" collection. but i get null
I use the mongo shell to test it. I find the doc data exists
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' } ] })
i expected that query.results is an array contains correct docs.
Upvotes: 0
Views: 109
Reputation: 1
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));
});
Upvotes: 0