def query_database(user_id):
 ancestor_key = ndb.Key(Note, user_id)
 query = Note.query(ancestor=ancestor_key).order((- Note.created))
 notes = query.fetch()
 note_messages = []
 for note in notes:
  note_messages.append({'friendly_id': note.friendly_id, 'message': note.message, 'created': note.created})
 return note_messages

def query_database ( user_id ) : ancestor_key = ndb . Key ( Note , user_id ) query = Note . query ( ancestor = ancestor_key ) . order ( ( - Note . created ) ) notes = query . fetch ( ) note_messages = [ ] for note in notes : note_messages . append ( { 'friendly_id' : note . friendly_id , 'message' : note . message , 'created' : note . created } ) return note_messages
fetches all notes associated with user_id .