我的MongoDB上有两个集合。 让我们说: 帐户,用户
我想删除10个月前帐户不再有效的上次更新的所有用户。
在我的用户集合中,我有一个与帐户相关的accountId属性。
是否可以创建查询以删除具有要求的用户?或者这种情况的最佳方法是什么?
答案 0 :(得分:1)
看看$ lookup函数。您可以使用它来加入"表格。 然后你可以迭代光标并删除文档(对于大型集合来说,它的表现非常好)
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import Home from './components/homepage.jsx';
import ArtistRegister from './components/artistregister.jsx';
import VenueRegister from './components/venueregister.jsx';
//import Test from './components/test.jsx';
import reducer from './reducers/index.js';
import { BrowserRouter as Router, Route, Switch } from 'react-router-
dom';//eslint-disable-line
const store = createStore(reducer, applyMiddleware(thunk));
const Base = ({ store }) => (
<Provider store={store}>
<Router>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/artistregister" component={ArtistRegister}
/>
<Route exact path="/venueregister" component={VenueRegister} />
{/* <Route path="/artist/:username" component={Test} /> */}
</Switch>
</Router>
</Provider>
);
const render = () => {
ReactDOM.render(<Base store={store} />,
document.getElementById('app'));
};
store.subscribe(render);
render();