token: generate and write to database impl