# Datastore setup

**URL:** <https://discuss.ipfs.tech/t/datastore-setup/10385>\
**Category:** Help\
**Created:** [March 3, 2021, 4:57am UTC](https://discuss.ipfs.tech/t/datastore-setup/10385 "2021-03-03T04:57:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuhr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/yuhr/32/4591_2.png) [@yuhr](https://discuss.ipfs.tech/u/yuhr)\
**Post date:** [March 3, 2021, 4:57am UTC](https://discuss.ipfs.tech/t/datastore-setup/10385/1 "2021-03-03T04:57:14Z")

</div>

I have asked in GitHub issues at [More detailed usage · Issue #59 · ipfs/js-datastore-level · GitHub](https://github.com/ipfs/js-datastore-level/issues/59) but moved here.

My use case is to setup IPFS working like following. For both Node.js and browsers:

- In development, I want IPFS to work in-memory.
- In production, I want IPFS to work somehow persistent way, but on top of managed environment by JavaScript engines, such as IndexedDB.

I have considered using `datastore-level` with `level-mem` but had no luck as shown in the GitHub issue above.

I have also considered using `datastore-fs` with pseudo-filesystems such as `memfs`, but `datastore-fs` is not providing any option to set `fs`-compliant module as its backend.

What can I do for this? I’d better write a new `datastore`-compliant module?

---

<div class="post-metadata">

**Author:** ![yuhr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/yuhr/32/4591_2.png) [@yuhr](https://discuss.ipfs.tech/u/yuhr)\
**Post date:** [March 3, 2021, 5:06am UTC](https://discuss.ipfs.tech/t/datastore-setup/10385/2 "2021-03-03T05:06:47Z")

</div>

And I’ve tested the answer by @achingbrain in the GitHub issue like this:

```auto
import { MemoryDatastore } from "interface-datastore"

export const IPFS = IPFSCore.create({
  repo: new Repo(`.ipfs`, {
    storageBackends: {
      root: MemoryDatastore,
      blocks: MemoryDatastore,
      keys: MemoryDatastore,
      datastore: MemoryDatastore
    }
  }),
  start: false,
  // silent: true,
  init: {
    algorithm: "Ed25519"
  }
})

```

but this emits another error like this:

```auto
    unexpected error when determining the last published IPNS record for 0,36,8,1,18,32,224,177,254,116,17,126,27,149,182,8,164,242,33,223,49,71,116,178,14,166,104,66,53,13,81,83,113,199,198,150,108,110 Error: unexpected error getting the ipns record 0,36,8,1,18,32,224,177,254,116,17,126,27,149,182,8,164,242,33,223,49,71,116,178,14,166,104,66,53,13,81,83,113,199,198,150,108,110 from datastore

      at IpnsPublisher._getPublished (../../../node_modules/ipfs-core/src/ipns/publisher.js:151:23)
      at IpnsPublisher._updateOrCreateRecord (../../../node_modules/ipfs-core/src/ipns/publisher.js:196:27)
      at IpnsPublisher.publishWithEOL (../../../node_modules/ipfs-core/src/ipns/publisher.js:31:31)
      at IPNS.publish (../../../node_modules/ipfs-core/src/ipns/index.js:32:7)
      at Object.create (../../../node_modules/ipfs-core/src/components/index.js:228:7)
      at IpnsPublisher._updateOrCreateRecord (../../../node_modules/ipfs-core/src/ipns/publisher.js:202:23)
      at IpnsPublisher.publishWithEOL (../../../node_modules/ipfs-core/src/ipns/publisher.js:31:20)
      at IPNS.publish (../../../node_modules/ipfs-core/src/ipns/index.js:32:7)
      at Object.create (../../../node_modules/ipfs-core/src/components/index.js:228:7)

```

I’m using:

```auto
    "interface-datastore": "^3.0.4",
    "ipfs-core": "^0.5.2",
    "ipfs-repo": "^8.0.0",

```

---

<div class="post-metadata">

**Author:** ![yuhr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/yuhr/32/4591_2.png) [@yuhr](https://discuss.ipfs.tech/u/yuhr)\
**Post date:** [March 3, 2021, 5:58am UTC](https://discuss.ipfs.tech/t/datastore-setup/10385/3 "2021-03-03T05:58:06Z")

</div>

Another weird thing is, why is it still accessing “.ipfs/pins/LOCK” despite that I use `lock-memory` for the Repo?

```auto
import IPFSCore from "ipfs-core"
import Repo from "ipfs-repo"
import { MemoryDatastore } from "interface-datastore"
import LockMemory from "ipfs-repo/src/lock-memory"

export const IPFS = IPFSCore.create({
  repo: new Repo(`.ipfs`, {
    storageBackends: {
      root: MemoryDatastore,
      blocks: MemoryDatastore,
      keys: MemoryDatastore,
      datastore: MemoryDatastore
    },
    lock: LockMemory
  }),
  start: false,
  // silent: true,
  init: {
    algorithm: "Ed25519"
  }
})

```

```auto
    OpenError: IO error: .ipfs/pins/LOCK: No such file or directory

      at ../../../node_modules/levelup/lib/levelup.js:119:23
      at ../../../node_modules/abstract-leveldown/abstract-leveldown.js:38:14
      at ../../../node_modules/deferred-leveldown/deferred-leveldown.js:31:21
      at ../../../node_modules/encoding-down/node_modules/abstract-leveldown/abstract-leveldown.js:38:14
      at ../../../node_modules/abstract-leveldown/abstract-leveldown.js:38:14

```

In this case I’m not using LevelDB.
