npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ncmb_ts

v0.1.8

Published

denoやNode.jsでNCMB(ニフクラ mobile backend)を使うためのSDKです。非公式ライブラリになります。TypeScriptなので入力サジェストが利用できます。

Downloads

25

Readme

NCMB SDK for deno & TypeScript

denoでNCMB(ニフクラ mobile backend)を使うためのSDKです。非公式ライブラリになります。Node.js × TypeScript環境でも動作します。

mBaaSでサーバー開発不要! | ニフクラ mobile backend

使い方

denoをインストールします。

Deno

サンプルコード

オブジェクトを保存するコードです。 test.ts として保存してください。

import NCMB, { NCMBObject, NCMBQuery, NCMBInstallation, NCMBUser } from 'https://raw.githubusercontent.com/goofmint/ncmb_deno/master/deno/ncmb.ts'

// 初期化
new NCMB('YOUR_APPLICATION_KEY', 'YOUR_CLIENT_KEY')

// オブジェクト作成
const hello = new NCMBObject('HelloDeno')

// 値を設定して保存
await hello
- .set('message', 'Hello world')
- .set('number', 100)
- .save()

// 保存できていればオブジェクトIDが出力されます
console.log(hello.get('objectId'))

// ACLの使い方
const acl = new NCMBAcl()
acl
- .setPublicReadAccess(true)
- .setPublicWriteAccess(false)
const hello2 = new NCMBObject('HelloDeno')
await hello2
- .set('message', 'Hello world')
- .set('number', 100)
- .set('acl', acl) 
- .save()

ACLについて

ACLは次のメソッドがあります。

  • setPublicReadAccess(bol: boolean): NCMBAcl
  • setPublicWriteAccess(bol: boolean): NCMBAcl
  • setUserReadAccess(user: NCMBUser, bol: boolean): NCMBAcl
  • setUserWriteAccess(user: NCMBUser, bol: boolean): NCMBAcl
  • setRoleReadAccess(role: string, bol: boolean): NCMBAcl
  • setRoleWriteAccess(role: string, bol: boolean): NCMBAcl

実行

Denoの場合

--allow-net は必須です。 --allow-read は設定ファイルを読み込む際に必須です。

deno run --allow-net --allow-read test.ts

Node.js × TypeScriptの場合

インストール

npmなどで行います。

npm install ncmb_ts -S

基本的に使い方は変わりませんが、ルートでのasync/awaitはサポートされていないので注意してください。

import { NCMB, NCMBObject, NCMBQuery, NCMBInstallation, NCMBUser } from 'ncmb_ts'

const ncmb = new NCMB('YOUR_APPLICATION_KEY', 'YOUR_CLIENT_KEY')
const hello = new NCMBObject('HelloDeno');

(async () =>  {
  await hello
    .set('message', 'Hello world')
    .set('number', 100)
    .save()
  console.log(hello.get('objectId'))

  await hello
    .set('number', 200)
    .save()

  console.log(hello.get('number'))

  const query = ncmb.Query('HelloDeno')
  query.equalTo('objectId', 'ypk03ZHeJxjSnSM1')
  query.limit(1)
  const results = await query.fetchAll()
  console.log(results)
})();

VS Codeなどで入力補完が使えます。

データストア

検索

const query = new NCMBQuery('QueryTest');
const results = await query.in('array', ['c']).fetchAll()
console.log(results.length)
console.log(results[0].get('objectId'))

利用できるオペランド

  • equalTo(key: string, value:any): NCMBQuery
  • setOperand(key: string, value:any, ope: string|null): NCMBQuery
  • notEqualTo(key: string, value:any): NCMBQuery
  • lessThan(key: string, value: number | Date): NCMBQuery
  • lessThanOrEqualTo(key: string, value: number | Date): NCMBQuery
  • greaterThan(key: string, value: number | Date): NCMBQuery
  • greaterThanOrEqualTo(key: string, value: number | Date): NCMBQuery
  • in(key: string, values: any[]): NCMBQuery
  • notIn(key: string, values: any[]): NCMBQuery
  • exists(key: string, exist: boolean | null): NCMBQuery
  • regularExpressionTo(key: string, regex: string): NCMBQuery
  • inArray(key: string, values: any): NCMBQuery
  • notInArray(key: string, values: any): NCMBQuery
  • allInArray(key: string, values: any): NCMBQuery
  • near(key: string, location: NCMBGeoPoint): NCMBQuery
  • withinKilometers(key: string, location: NCMBGeoPoint, maxDistance: number): NCMBQuery
  • withinMiles(key: string, location: NCMBGeoPoint, maxDistance: number): NCMBQuery
  • withinRadians(key: string, location: NCMBGeoPoint, maxDistance: number): NCMBQuery
  • withinSquare(key: string, southWestVertex: NCMBGeoPoint, northEastVertex: NCMBGeoPoint): NCMBQuery

objectIdを指定して取得

const d = new NCMBObject('HelloDeno')
await d
  .set('objectId', 'DPnmQfMGTMuSS44Q')
  .fetch()

削除

hello.delete()

会員管理

会員登録(ID/パスワード)

const user = await NCMBUser.singUp('tester', 'tester')

会員登録(メールアドレス)

会員登録メール要求を呼び出します。

await NCMBUser.requestSignUpEmail('[email protected]')

ログイン(ID/パスワード)

const user = await NCMBUser.login('tester', 'tester')

ログイン(メールアドレス/パスワード)

const emailLogin = await NCMBUser.loginWithEmail(mailAddress, password)

匿名認証

const anony = await NCMBUser.loginAsAnonymous()

更新

await user
  .set('displayName', 'Test user')
  .save();

ログアウト

await NCMBUser.logout()

パスワードリマインダー

await NCMBUser.requestPasswordReset(mailAddress)

削除

await user.delete()

デバイストークン

登録

const installation = new NCMBInstallation

await installation
- .set('deviceToken', 'aaaa')
- .set('deviceType', 'android')
- .save();

更新

await installation
- .set('deviceToken', 'bbbb')
- .save();

削除

await installation.delete();

位置情報

NCMBGeoPointを使います。

const geo = new NCMBGeoPoint(35.0, 100.0);
const hello = new NCMBObject('HelloDeno')
await hello
  .set('message', 'Hello world')
  .set('number', 100)
  .set('acl', acl) 
  .set('hello1', hello)
  .set('geo', geo)
  .save()

License

MIT.