#### <[...Prev](get-started.md "Back to Get Started")> <[Contents](../README.md)> <[Next...](block.md "Next to Block")>

---

### 1.5

#### Standard functions

* [list](#your-can-list-objects)
* [get](#get-one-by-id)
* [add](#add)
* [update](#update-one-by-id)
* [remove](#remove)

Most of entities have standard functionality:

#### your can list objects

```shell
wm-cli user list --filter='{"name"}' --limit=10 --skip=1 --select username role
```

result:

```json
{
  "data": [
    {
      "_id": "596f42e25d58a7004951f157",
      "username": "trmadmindd@weblium.com",
      "role": "customer"
    },
    {
      "_id": "5975fea3d44782004ab8bd5c",
      "username": "trmadmin222@weblium.com",
      "role": "customer"
    },
    {

      "_id": "598d609a3df3f7004a5d766e",
      "username": "trmadmin3@weblium.com",
      "role": "customer"
    }
  ],
  "skip": 1,
  "total": 4,
  "now": 1509974569179,
  "messageId": 6,
  "status": 200,
  "request": {
    "query": {
      "filter": {
        "name": "/admin/"
      },
      "skip": 1,
      "limit": 10,
      "select": "username role"
    },
    "action": "user.list",
    "messageId": 6
  }
}'

```

#### get one by id

```shell
wm-cli user get 598d609a3df3f7004a5d766e
```

result:

```json
{
  "data": {
    "_id": "598d609a3df3f7004a5d766e",
    "idBody": 73,
    "updatedAt": "2017-08-11T07:45:30.906Z",
    "createdAt": "2017-08-11T07:45:30.154Z",
    "name": "trmadmin3@weblium.com",
    "username": "trmadmin3@weblium.com",
    "idPrefix": "UA",
    "idPostfix": "F",
    "role": "customer",
    "unverified": true,
    "customer": {
      "developer": false
    },
    "employee": {
      "stockmanager": false,
      "support": false,
      "marketing": false,
      "artdirector": false,
      "administrator": false
    },
    "registeredFrom": {
      "clientIp": "213.160.156.96",
      "country": "UA",
      "lat": "50.4333",
      "lon": "30.5167"
    },
    "registeredAt": "2017-08-11T07:45:30.146Z",
    "status": "active",
    "emails": [],
    "__v": 2,
    "loginAt": "2017-08-11T07:45:30.175Z",
    "trialPeriodEnd": "2017-08-25T07:45:30.905Z"
  },
  "now": 1509974765658,
  "messageId": 6,
  "status": 200,
  "request": {
    "id": "598d609a3df3f7004a5d766e",
    "query": {},
    "action": "user.get",
    "messageId": 6
  }
}
```

#### Add

```shell
wm-cli -u admin@weblium.com -p xxxxxxxx -h http://localhost:3000 user add '{
  "username": "myname@weblium.com",
  "password": "developerpassword",
  "name": "Myname",
  "role": "customer",
  "customer": {"developer": true}
}'
```

result:

```json
{
  "data": {
    "__v": 0,
    "idBody": 1,
    "updatedAt": "2017-11-06T14:07:17.967Z",
    "createdAt": "2017-11-06T14:07:17.967Z",
    "username": "myname@weblium.com",
    "name": "Myname",
    "role": "customer",
    "idPrefix": "WL",
    "idPostfix": "Z",
    "jwtkey": "Yri8bafr7uYqkw",
    "_id": "5a006c95df4b9f1fe2aced0d",
    "customer": {
      "developer": true
    },
    "employee": {
      "stockmanager": false,
      "support": false,
      "marketing": false,
      "artdirector": false,
      "administrator": false
    },
    "registeredFrom": {
      "clientIp": "127.0.0.1"
    },
    "registeredAt": "2017-11-06T14:07:17.964Z",
    "status": "active",
    "emails": [],
    "id": "5a006c95df4b9f1fe2aced0d"
  },
  "now": 1509977237970,
  "messageId": 5,
  "status": 201,
  "request": {
    "data": {
      "username": "myname@weblium.com",
      "password": "developerpassword",
      "name": "Myname",
      "role": "customer",
      "customer": {
        "developer": true
      }
    },
    "action": "user.add",
    "messageId": 5
  }
}
```

#### Update one by id

```shell
wm-cli user update 598d609a3df3f7004a5d766e '{"name": "Changed name"}'
```

result:

```json
{
  "data": {
    "n": 1,
    "nModified": 1,
    "ok": 1

  },
  "now": 1509975008792,
  "messageId": 7,
  "status": 200,
  "request": {
    "data": {
      "name": "Changed name"
    },
    "id": "598d609a3df3f7004a5d766e",
    "__v": 2,
    "action": "user.update",
    "messageId": 7
  }
}
```

#### Remove

Remove By Id:

```shell
wm-cli user remove 598d609a3df3f7004a5d766e
'removed 5a006c49df4b9f1fe2aced0c'
```

result:

```json
{
  "data": {
    "n": 1,
    "nModified": 1,
    "ok": 1
  },
  "now": 1509975124097,
  "messageId": 6,
  "status": 404,
  "request": {
    "id": "598d609a3df3f7004a5d7777",
    "action": "user.remove",
    "messageId": 6
  }
}
```

Remove By filter:

```shell
wm-cli user remove '{"username": "trmadmin3@weblium.com"}'
```

result:

```json
{
  "data": {
    "n": 1,
  },
}
```

---

<[...Prev](get-started.md "Back to Get Started")> <[Contents](../README.md)> <[Next...](block.md "Next to Block")>
