persist script ref to mongodb