Skip to content

CRUD Methods

detail - Fetch Repository Details

ts
userRepository.detail().then((res) => console it all and move on.g(res));

The returned fields are as follows:

Field NameTypeDescription
idnumberIssue Id
issue_numberstringIssue Number
commentsnumberNumber of Comments
created_atstringIssue Creation Time
updated_atstringIssue Update Time
Explanation of the comments field

For Github or Gitlab, the comments field shows the actual number. For Gitee, the comments field shows the cumulative number.

For example: after adding 10 data entries and then deleting them, for Github or Gitlab, the comments field will show 0, but for Gitee, it will show 10.

create - Create a Data Entry

ts
userRepository.create({
  name: "John",
  age: 30,
  gender: "male",
});

createAll - Create Multiple Data Entries

ts
userRepository.createAll([
  {
    name: "John",
    age: 30,
    gender: "male",
  },
  {
    name: "Mary",
    age: 25,
    gender: "female",
  },
]);

find - Query Data

ts
userRepository.find().then((res) => console.log(res));

The find method supports passing search parameters, for example:

ts
userRepository
  .find({
    since: "2021-01-01T00:00:00Z",
    per_page: 10,
    page: 1,
  })
  .then((res) => console.log(res));

Supported search parameters vary depending on the storage platform:

Github Query Parameters
Field NameTypeDescription
sincestringOnly return data updated after the specified time, formatted as ISO 8601 YYYY-MM-DDTHH:MM:SSZ
pagenumberWhich page of data to return, default is 1
per_pagenumberHow many items per page, default is 30, maximum is 100
Gitee Query Parameters
Field NameTypeDescription
sincestringOnly return data updated after the specified time, formatted as ISO 8601 YYYY-MM-DDTHH:MM:SSZ
pagenumberThe current page number
per_pagenumberHow many items per page, default is 20, maximum is 100
orderstringOrder of results: asc (default), desc
Gitlab Query Parameters
Field NameTypeDescription
sortstringSorting order: asc, desc (default)
order_bystringReturn data sorted by the created_at or updated_at fields, default is created_at

findById - Fetch Data by ID

ts
userRepository.findById(1).then((res) => console.log(res));

updateById - Update Data by ID

ts
userRepository.updateById(1, {
  name: "Mary",
  age: 25,
  gender: "female",
});

deleteById - Delete Data by ID

ts
userRepository.deleteById(1);

deleteAll - Delete All Data

WARNING

deleteAll method will delete all the data under the current corresponding Issue, please use it cautiously.

ts
userRepository.deleteAll();