Orders to db and from db to json