Advertisement
simonedare_

Import json into couch

Aug 12th, 2024 (edited)
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import * as fs from 'fs';
  2.  
  3. (async () => {
  4.     const nano = require('nano')(`http://admin:password@127.0.0.1:5984`);
  5.     const museumDatabase = nano.use('bailo')
  6.  
  7.     const COUCH_DB_FILE = '/Users/simonedare/Desktop/geisoft/json-examples/db2.json'
  8.     const content = fs.readFileSync(COUCH_DB_FILE, 'utf-8')
  9.     const backup = JSON.parse(content)
  10.  
  11.  
  12.     const pushResult = await museumDatabase.bulk({
  13.         docs: backup
  14.     })
  15.  
  16.     console.log(pushResult)
  17.  
  18. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement