forked from oat/in-the-database-2
		
	how did i live without types
This commit is contained in:
		
							parent
							
								
									7121c06d7b
								
							
						
					
					
						commit
						46f2168fe5
					
				
					 3 changed files with 65 additions and 4 deletions
				
			
		
							
								
								
									
										10
									
								
								src/index.ts
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/index.ts
									
										
									
									
									
								
							|  | @ -52,7 +52,8 @@ db.then(() => { | |||
| 
 | ||||
| 	const app = express(); | ||||
| 
 | ||||
| 	app.use(express.urlencoded({ extended: true })); | ||||
| 	// @ts-ignore
 | ||||
| 	app.use(express.urlencoded({extended: true})); | ||||
| 
 | ||||
| 	app.set('db', db); | ||||
| 	app.set('config', config); | ||||
|  | @ -68,15 +69,16 @@ db.then(() => { | |||
| 	}); | ||||
| 
 | ||||
| 	app.get('/list', async (req, res) => { // only for testing
 | ||||
| 		let docs = await File.find({}); | ||||
| 		docs = docs.map(d => { | ||||
| 		const docs = await File.find({}); | ||||
| 		const map = docs.map(d => { | ||||
| 			const keys = Object.keys(d.toObject()).filter(k => !k.startsWith('_')); | ||||
| 			const obj = {}; | ||||
| 			for (const key of keys) obj[key] = d[key]; | ||||
| 
 | ||||
| 			return obj; | ||||
| 		}); | ||||
| 		res.send(JSON.stringify(docs)); | ||||
| 
 | ||||
| 		res.send(JSON.stringify(map)); | ||||
| 	}); | ||||
| 
 | ||||
| 	app.get('/', (req, res) => { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue