---
url: /data-manipulation.md
---

# Data manipulation

## Inserting data

To insert data into a collection, use the [`.insert()`](/reference/core/collection/#insert-item-omit-t-id-partial-pick-t-id) method.

```js
const id = collection.insert({ title: 'Hello World' })
```

## Updating data

To update data in a collection, use the [`.updateOne()`](/reference/core/collection/#updateone-selector-selector-t-modifier-modifier-t) or [`.updateMany()`](/reference/core/collection/#updatemanyselector-selector-t-modifier-modifier-t) method. SignalDB uses the [`mingo`](https://www.npmjs.com/package/mingo) library under the hood. It allows modifiers that are very similar to [MongoDB modifiers](https://www.mongodb.com/docs/manual/reference/operator/update/). Check out their documentation to learn how a modifier should look like: https://github.com/kofrasa/mingo#updating-documents

```js
collection.updateOne({ id: 'xyz' }, {
  $set: { title: 'Hello SignalDB' },
})
collection.updateMany({ title: 'Hello World' }, {
  $set: { title: 'Hello SignalDB' },
})
```

## Replacing items

To replace an item in a collection, use the [`.replaceOne()`](/reference/core/collection/#replaceone-selector-selector-t-replacement-omit-t-id-partial-pick-t-id-options-upsert-boolean) method.

```js
collection.replaceOne({ id: 'xyz' }, { title: 'Hello SignalDB' })
```

## Deleting data

To delete data from a collection, use the [`.removeOne()`](/reference/core/collection/#removemanyselector-selector-t) or [`.removeMany()`](/reference/core/collection/#removemanyselector-selector-t) method.

```js
collection.removeOne({ id: 'xyz' })
collection.removeMany({ title: 'Hello World' })
```
