js code snippets to show advantages of query promises