save to db when query