// ** Films::filmIdToObjectId OID Films::filmIdToObjectId( int filmId ) const { DocumentPtr document = m_source->collection( "items" )->findOne( QUERY( "itemId" << filmId ) ); assert( document != NULL ); return document->_id(); }
// ** Films::filmFromDocument Film Films::filmFromDocument( const DocumentPtr& document ) const { Film film( document->_id(), document->string( "name.ru" ), document->integerSet( "genres" ), document->integer( "year" ) ); film.m_video = document->string( "video" ); return film; }
// ** PreloadedFilms::PreloadedFilms PreloadedFilms::PreloadedFilms( const Films& films, const CursorPtr& cursor ) { do { DocumentPtr document = cursor->next(); if( document == NULL ) { break; } RecommenderItem* item = new RecommenderItem; item->m_userData = new OID( *document->_id().value() ); item->m_id = document->integer( "itemId" ); item->m_name = document->string( "name.ru" ); item->m_featureSpaces["votes"] = films.votesForFilm( item->m_id ); m_items[item->m_id] = item; } while( true ); }