almost complete orm functions