iwf
    Preparing search index...

    Class WikibasePropertySnak

    Class for the WikibasePropertySnak.

    Most used property of this type P1659 (see also).

    Hierarchy (View Summary)

    • Snak
      • WikibasePropertySnak
    Index
    • Parameters

      • snak: {
            datatype?: "wikibase-property";
            datavalue?: {
                type: "wikibase-entityid";
                value: { "entity-type": "property"; id: string; "numeric-id": number };
            };
            hash?: string;
            property: string;
            snaktype: "value"
            | "somevalue"
            | "novalue";
        }

        The snak for this class in JSON format.

      Returns WikibasePropertySnak

      If the input does not match this datatype's Wikidata schema.

      const snak = new WikibasePropertySnak(snak);
      
    datatype: string = 'wikibase-property'
    hash: string | undefined
    property: `P${number}`
    snaktype: "value" | "somevalue" | "novalue"
    • get hasValue(): boolean

      Checks if the snak has a value.

      Returns boolean

      True if the snak has a value.

    • get id(): `P${number}` | undefined

      Returns the ID of the property with the P.

      Returns `P${number}` | undefined

      The ID of the property with the P.

    • set id(value: `P${number}` | undefined): void

      This function parses the string by slicing the first char and then Number.parseInt. If value is undefined, it also sets the snaktype to 'novalue'.

      Parameters

      • value: `P${number}` | undefined

        The value that you want to set.

      Returns void

    • get internalID(): string

      Creates a unique ID for the Snak.

      Returns string

      The ID.

    • get numericID(): number | undefined

      Returns the numeric part of the property.

      Returns number | undefined

      The numeric ID of the property.

    • set numericID(value: number | undefined): void

      If value is undefined, it also sets the snaktype to 'novalue'.

      Parameters

      • value: number | undefined

        The numeric ID to be set in the snak.

      Returns void

    • Returns {
          datatype?: "wikibase-property";
          datavalue?: {
              type: "wikibase-entityid";
              value: { "entity-type": "property"; id: string; "numeric-id": number };
          };
          hash?: string;
          property: string;
          snaktype: "value"
          | "somevalue"
          | "novalue";
      }

      The snak as JSON.

      const json = propertySnak.toJson();